QTest、mousePress和mouseMove:Qt测试中缺少拖放事件
我有一个带有QTreeView和qgraphicsceneview的GUI 树视图使用的模型支持拖动事件,图形场景支持拖放事件 我想用QTest模拟用户操作:QTest、mousePress和mouseMove:Qt测试中缺少拖放事件,qt,user-interface,testing,pyqt,qttest,Qt,User Interface,Testing,Pyqt,Qttest,我有一个带有QTreeView和qgraphicsceneview的GUI 树视图使用的模型支持拖动事件,图形场景支持拖放事件 我想用QTest模拟用户操作:mousePress、mouseMove、mouseRelease等等 我写这段代码: item_rect = self.main_wnd.tree_view.visualRect(constant_index) QtTest.QTest.mouseMove(self.main_wnd.tree_view.viewport(), item
mousePress
、mouseMove
、mouseRelease
等等
我写这段代码:
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)
在这里,我的鼠标真的移动到树项rect,选择它——并移动到场景的中心,而无需任何拖放操作。
你能告诉我,我如何修复它吗?可能是个bug。我用C++编写了一个测试,调试后发现