Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-60234

Cannot test drag and drop with QTest

    XMLWordPrintable

Details

    Description

      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 in PyQt:

      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 it be somehow fixed?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            macadder Jason McDonald
            alexey.golovizin Alexey Golovizin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes