diff options
author | Thomas Zander <thomas.zander@trolltech.com> | 2009-10-19 17:11:19 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-10-22 14:59:19 (GMT) |
commit | 0f1f53414de3e7d1b62149ee42a334c6f2d01f78 (patch) | |
tree | 31594cd62f1224ba5d59896fa28c68f960cb8ef4 /tests | |
parent | 75599a71e957cae29ddd4d3df9e89d9d4edc0b3d (diff) | |
download | Qt-0f1f53414de3e7d1b62149ee42a334c6f2d01f78.zip Qt-0f1f53414de3e7d1b62149ee42a334c6f2d01f78.tar.gz Qt-0f1f53414de3e7d1b62149ee42a334c6f2d01f78.tar.bz2 |
Add QGestureEvent::mapToScene for better graphicsView integration
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gestures/tst_gestures.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 0c09265..09da7d6 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -320,6 +320,7 @@ private slots: void twoGesturesOnDifferentLevel(); void multipleGesturesInTree(); void multipleGesturesInComplexTree(); + void testMapToScene(); }; tst_Gestures::tst_Gestures() @@ -1046,5 +1047,30 @@ void tst_Gestures::multipleGesturesInComplexTree() QCOMPARE(A->events.all.count(SeventhGesture), 0); } +void tst_Gestures::testMapToScene() +{ + QGesture gesture; + QList<QGesture*> list; + list << &gesture; + QGestureEvent event(list); + QCOMPARE(event.mapToScene(gesture.hotSpot()), QPointF()); // not set, can't do much + + QGraphicsScene scene; + QGraphicsView view(&scene); + + GestureItem *item0 = new GestureItem; + scene.addItem(item0); + item0->setPos(14, 16); + + view.show(); // need to show to give it a global coordinate + QTest::qWaitForWindowShown(&view); + view.ensureVisible(scene.sceneRect()); + + QPoint origin = view.mapToGlobal(QPoint()); + event.setWidget(view.viewport()); + + QCOMPARE(event.mapToScene(origin + QPoint(100, 200)), view.mapToScene(QPoint(100, 200))); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" |