I was not able to simulate drag and drop through the QTest mouse functions, and digia says they do not add this functionality to QT4. I implemented drag and drop testing using a method similar to the method suggested in the link above:
create mime_data, something like:
mime_data = widget_model.mimeData(indexes)
or
mime_data = QMimeData() mime_data.setText(widget.text())
then use this function to delete the data:
def dropOnto(self, widget, mime_data): action = Qt.CopyAction|Qt.MoveAction pt = widget.rect().center() drag_drop = QDropEvent(pt, action, mime_data, Qt.LeftButton, Qt.NoModifier) drag_drop.acceptProposedAction() widget.dropEvent(drag_drop)
source share