3

I have a GUI with QTreeView and QGraphicsSceneView.

The model used by the tree view supports drag events and graphics scene supports drop events.

I want to simulate user actions with QTest: mousePress, mouseMove, mouseRelease and so on.

I write this code:

item_rect = self.main_wnd.tree_view.visualRect(constant_index)

QtTest.QTest.mouseMove(self.main_wnd.tree_view.viewport(), item_rect.center(), 300)
QtTest.QTest.mousePress(self.main_wnd.tree_view.viewport(), QtCore.Qt.LeftButton, QtCore.Qt.KeyboardModifiers(),
                            item_rect.center(), 300)

QtTest.QTest.mouseMove(self.main_wnd._scene_views[None].viewport(), QtCore.QPoint(), 300)
QtTest.QTest.mouseRelease(self.main_wnd.tree_view.viewport(), QtCore.Qt.LeftButton, QtCore.Qt.KeyboardModifiers(),
                            constant_rect.center(), 300)

Here my mouse really moves to the tree item rect, selects it -- and moves to the center of the scene without any dragging or dropping.

Can you tell me, how can I fix it?

Felix
  • 3,351
  • 6
  • 40
  • 68
  • It's probably a bug. I have a test written in c++, and after debugging I found out that `QTest::mouseMove` never trigger any event. see https://bugreports.qt.io/browse/QTBUG-5232 . Sadly, I don't know anything I can do. – RnMss Jan 19 '18 at 17:01

0 Answers0