summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsview
diff options
context:
space:
mode:
authorBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-05-05 13:33:42 (GMT)
committerBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-05-05 14:40:05 (GMT)
commit2137f41ca0df3c83abce9dd386074e0fd09a33dc (patch)
treed1d187cdbe2c26ab523318218781c949f081e33a /tests/auto/qgraphicsview
parenta5c9793ea6b5590f1033546856c34eaee6352d58 (diff)
downloadQt-2137f41ca0df3c83abce9dd386074e0fd09a33dc.zip
Qt-2137f41ca0df3c83abce9dd386074e0fd09a33dc.tar.gz
Qt-2137f41ca0df3c83abce9dd386074e0fd09a33dc.tar.bz2
Partially revert 37c72476fc444d3089075473cb4e9aa42ed64694
The problem was that mouse move events were not forwarded to the scene when mouse tracking was explicitly enabled on the view. Mouse tracking is disabled by default unless the scene contains an item that accepts hover events or has a cursor set. A mouse move event can only occur if: 1) a mouse button is pressed while moving the mouse 2) mouse tracking is enabled That means the part I've reverted was only hitting when mouse tracking was explicitly enabled, which is wrong. We always have to forward mouse move events to the scene if the view is getting them in the first place. Auto test included. Reviewed-by: Andreas
Diffstat (limited to 'tests/auto/qgraphicsview')
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index ca88afc..bb61f90 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -190,6 +190,7 @@ private slots:
void scrollAfterResize();
void centerOnDirtyItem();
void mouseTracking();
+ void mouseTracking2();
// task specific tests below me
void task172231_untransformableItems();
@@ -3173,5 +3174,31 @@ void tst_QGraphicsView::mouseTracking()
}
}
+void tst_QGraphicsView::mouseTracking2()
+{
+ // Make sure mouse move events propagates to the scene when
+ // mouse tracking is explicitly enabled on the view,
+ // even when all items ignore hover events / use default cursor.
+
+ QGraphicsScene scene;
+ scene.addRect(0, 0, 100, 100);
+
+ QGraphicsView view(&scene);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(200);
+
+ QVERIFY(!view.viewport()->hasMouseTracking());
+ view.viewport()->setMouseTracking(true); // Explicitly enable mouse tracking.
+ QVERIFY(view.viewport()->hasMouseTracking());
+
+ EventSpy spy(&scene, QEvent::GraphicsSceneMouseMove);
+ QCOMPARE(spy.count(), 0);
+ sendMouseMove(view.viewport(), view.viewport()->rect().center());
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QGraphicsView)
#include "tst_qgraphicsview.moc"