QTest: Can I check the drag and drop?

I am trying to test drag & drop with a simple sequince: mousePress + mouseMove + mouseRelease. But that does not work.

I examine the source of qtest and find that the move event is checked through the main processEvent () dispatcher. I also found some errors in the qt error: 1 , 2

So, I think it is not possible to test drag & drop in the latest stable Qt4. Does anyone have a success story with this?

+4
source share
1 answer

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) 
0
source

All Articles