I have a pretty complicated QGraphicsView / Scene setting where I have elements with complex interactions.
As such, I want a unit test to avoid creating errors in existing functions. For one test, I want:
- Click on an item in the scene.
- Move your mouse right
- Release the mouse button
This will allow me to verify that the item has been selected, has been moved by the desired amount and not selected.
However, I found that after dispatching mouseMove events, the state of the mouse becomes “released”, here is my code:
QTest.mousePress(gv.viewport(), Qt.LeftButton, Qt.NoModifier, QPoint(80,80), 100)
QTest.mouseMove(gv.viewport(), QPoint(80,80), 200)
QTest.mouseMove(gv.viewport(), QPoint(90,80), 300)
QTest.mouseMove(gv.viewport(), QPoint(100,80), 400)
QTest.mouseRelease(gv.viewport(), Qt.LeftButton, Qt.NoModifier, QPoint(80,80), 900)
Where gv is QGraphicsView.
The problem seems to be that mouseMove events are visible as hoverMoveEvents using QGraphicsItem - this should be treated as mouseMoveEvent!
:
http://qt-project.org/doc/qt-4.8/qgraphicsitem.html#setAcceptHoverEvents
, , " "?
:
unit test /
Edit:
TL;DR; ? , QGraphicsItems mouseHover mouseMove.