Set target and device for touch events.
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Thu, 8 Dec 2011 10:46:47 +0000 (12:46 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 9 Dec 2011 20:23:00 +0000 (21:23 +0100)
The QWidget dependency is being removed from QTouchEvent and therefore
widget() will be removed. There will be QObject *target() instead.

deviceType() has been deprecated and is replaced by QTouchDevice
*device().

Change-Id: Ic07b2c620fbfc1ae2e5eff85c8fc7269c7d5e2a8
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
src/quick/items/qquickcanvas.cpp
tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp
tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp

index 5bf27de..d93f774 100644 (file)
@@ -1141,8 +1141,9 @@ bool QQuickCanvasPrivate::deliverTouchPoints(QQuickItem *item, QTouchEvent *even
 
         if (eventStates != Qt::TouchPointStationary) {
             QTouchEvent touchEvent(eventType);
-            // touchEvent.setWidget(q); // ### refactor: what is the consequence of not setting the widget?
-            touchEvent.setDeviceType(event->deviceType());
+            touchEvent.setWindow(event->window());
+            touchEvent.setTarget(item);
+            touchEvent.setDevice(event->device());
             touchEvent.setModifiers(event->modifiers());
             touchEvent.setTouchPointStates(eventStates);
             touchEvent.setTouchPoints(eventPoints);
index 60522b7..f8e3596 100644 (file)
@@ -73,18 +73,6 @@ static QTouchEvent::TouchPoint makeTouchPoint(QQuickItem *item, const QPointF &p
     return tp;
 }
 
-static TouchEventData makeTouchData(QEvent::Type type, QWidget *w, Qt::TouchPointStates states, const QList<QTouchEvent::TouchPoint> &touchPoints)
-{
-    TouchEventData d = { type, w, 0, states, touchPoints };
-    return d;
-}
-
-static TouchEventData makeTouchData(QEvent::Type type, QWidget *w, Qt::TouchPointStates states, const QTouchEvent::TouchPoint &touchPoint)
-{
-    QList<QTouchEvent::TouchPoint> points;
-    points << touchPoint;
-    return makeTouchData(type, w, states, points);
-}
 static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states, const QList<QTouchEvent::TouchPoint>& touchPoints)
 {
     TouchEventData d = { type, 0, w, states, touchPoints };
@@ -148,7 +136,7 @@ protected:
             event->ignore();
             return;
         }
-        lastEvent = makeTouchData(event->type(), event->widget(), event->touchPointStates(), event->touchPoints());
+        lastEvent = makeTouchData(event->type(), event->window(), event->touchPointStates(), event->touchPoints());
         event->accept();
     }
 
@@ -255,8 +243,12 @@ void tst_qquickcanvas::touchEvent_basic()
 
     QPointF pos(10, 10);
 
+    QTouchDevice *device = new QTouchDevice;
+    device->setType(QTouchDevice::TouchScreen);
+    QWindowSystemInterface::registerTouchDevice(device);
+
     // press single point
-    QTest::touchEvent(canvas).press(0, topItem->mapToScene(pos).toPoint(),canvas);
+    QTest::touchEvent(canvas, device).press(0, topItem->mapToScene(pos).toPoint(),canvas);
     QTest::qWait(50);
 
     QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
@@ -268,7 +260,7 @@ void tst_qquickcanvas::touchEvent_basic()
     topItem->reset();
 
     // press multiple points
-    QTest::touchEvent(canvas).press(0, topItem->mapToScene(pos).toPoint(),canvas)
+    QTest::touchEvent(canvas, device).press(0, topItem->mapToScene(pos).toPoint(),canvas)
             .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
     QTest::qWait(50);
     QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
@@ -280,9 +272,9 @@ void tst_qquickcanvas::touchEvent_basic()
     bottomItem->reset();
 
     // touch point on top item moves to bottom item, but top item should still receive the event
-    QTest::touchEvent(canvas).press(0, topItem->mapToScene(pos).toPoint(), canvas);
+    QTest::touchEvent(canvas, device).press(0, topItem->mapToScene(pos).toPoint(), canvas);
     QTest::qWait(50);
-    QTest::touchEvent(canvas).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
+    QTest::touchEvent(canvas, device).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
     QTest::qWait(50);
     QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
     COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved,
@@ -290,9 +282,9 @@ void tst_qquickcanvas::touchEvent_basic()
     topItem->reset();
 
     // touch point on bottom item moves to top item, but bottom item should still receive the event
-    QTest::touchEvent(canvas).press(0, bottomItem->mapToScene(pos).toPoint(), canvas);
+    QTest::touchEvent(canvas, device).press(0, bottomItem->mapToScene(pos).toPoint(), canvas);
     QTest::qWait(50);
-    QTest::touchEvent(canvas).move(0, topItem->mapToScene(pos).toPoint(), canvas);
+    QTest::touchEvent(canvas, device).move(0, topItem->mapToScene(pos).toPoint(), canvas);
     QTest::qWait(50);
     QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
     COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved,
@@ -300,9 +292,9 @@ void tst_qquickcanvas::touchEvent_basic()
     bottomItem->reset();
 
     // a single stationary press on an item shouldn't cause an event
-    QTest::touchEvent(canvas).press(0, topItem->mapToScene(pos).toPoint(), canvas);
+    QTest::touchEvent(canvas, device).press(0, topItem->mapToScene(pos).toPoint(), canvas);
     QTest::qWait(50);
-    QTest::touchEvent(canvas).stationary(0)
+    QTest::touchEvent(canvas, device).stationary(0)
             .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
     QTest::qWait(50);
     QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);    // received press only, not stationary
@@ -314,9 +306,9 @@ void tst_qquickcanvas::touchEvent_basic()
     bottomItem->reset();
 
     // move touch point from top item to bottom, and release
-    QTest::touchEvent(canvas).press(0, topItem->mapToScene(pos).toPoint(),canvas);
+    QTest::touchEvent(canvas, device).press(0, topItem->mapToScene(pos).toPoint(),canvas);
     QTest::qWait(50);
-    QTest::touchEvent(canvas).release(0, bottomItem->mapToScene(pos).toPoint(),canvas);
+    QTest::touchEvent(canvas, device).release(0, bottomItem->mapToScene(pos).toPoint(),canvas);
     QTest::qWait(50);
     QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
     COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased,
@@ -324,12 +316,12 @@ void tst_qquickcanvas::touchEvent_basic()
     topItem->reset();
 
     // release while another point is pressed
-    QTest::touchEvent(canvas).press(0, topItem->mapToScene(pos).toPoint(),canvas)
+    QTest::touchEvent(canvas, device).press(0, topItem->mapToScene(pos).toPoint(),canvas)
             .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
     QTest::qWait(50);
-    QTest::touchEvent(canvas).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
+    QTest::touchEvent(canvas, device).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
     QTest::qWait(50);
-    QTest::touchEvent(canvas).release(0, bottomItem->mapToScene(pos).toPoint(), canvas)
+    QTest::touchEvent(canvas, device).release(0, bottomItem->mapToScene(pos).toPoint(), canvas)
                              .stationary(1);
     QTest::qWait(50);
     QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
@@ -353,6 +345,10 @@ void tst_qquickcanvas::touchEvent_propagation()
     QFETCH(bool, enableItem);
     QFETCH(qreal, itemOpacity);
 
+    QTouchDevice *device = new QTouchDevice;
+    device->setType(QTouchDevice::TouchScreen);
+    QWindowSystemInterface::registerTouchDevice(device);
+
     QQuickCanvas *canvas = new QQuickCanvas;
     canvas->resize(250, 250);
     canvas->move(100, 100);
@@ -383,7 +379,7 @@ void tst_qquickcanvas::touchEvent_propagation()
     topItem->setOpacity(itemOpacity);
 
     // single touch to top item, should be received by middle item
-    QTest::touchEvent(canvas).press(0, pointInTopItem, canvas);
+    QTest::touchEvent(canvas, device).press(0, pointInTopItem, canvas);
     QTest::qWait(50);
     QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
     QCOMPARE(middleItem->lastEvent.touchPoints.count(), 1);
@@ -392,7 +388,7 @@ void tst_qquickcanvas::touchEvent_propagation()
             makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos))));
 
     // touch top and middle items, middle item should get both events
-    QTest::touchEvent(canvas).press(0, pointInTopItem, canvas)
+    QTest::touchEvent(canvas, device).press(0, pointInTopItem, canvas)
             .press(1, pointInMiddleItem, canvas);
     QTest::qWait(50);
     QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
@@ -409,7 +405,7 @@ void tst_qquickcanvas::touchEvent_propagation()
     middleItem->setOpacity(itemOpacity);
 
     // touch top and middle items, bottom item should get all events
-    QTest::touchEvent(canvas).press(0, pointInTopItem, canvas)
+    QTest::touchEvent(canvas, device).press(0, pointInTopItem, canvas)
             .press(1, pointInMiddleItem, canvas);
     QTest::qWait(50);
     QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
@@ -426,7 +422,7 @@ void tst_qquickcanvas::touchEvent_propagation()
     bottomItem->setOpacity(itemOpacity);
 
     // no events should be received
-    QTest::touchEvent(canvas).press(0, pointInTopItem, canvas)
+    QTest::touchEvent(canvas, device).press(0, pointInTopItem, canvas)
             .press(1, pointInMiddleItem, canvas)
             .press(2, pointInBottomItem, canvas);
     QTest::qWait(50);
@@ -442,7 +438,7 @@ void tst_qquickcanvas::touchEvent_propagation()
     middleItem->acceptEvents = acceptEvents;
     middleItem->setEnabled(enableItem);
     middleItem->setOpacity(itemOpacity);
-    QTest::touchEvent(canvas).press(0, pointInTopItem, canvas);
+    QTest::touchEvent(canvas, device).press(0, pointInTopItem, canvas);
     QTest::qWait(50);
     if (!enableItem || itemOpacity == 0) {
         // middle item is disabled or has 0 opacity, bottom item receives the event
index b4fca9b..59a913e 100644 (file)
 class tst_QQuickMultiPointTouchArea: public QObject
 {
     Q_OBJECT
+public:
+    tst_QQuickMultiPointTouchArea() : device(0) { }
 private slots:
-    void initTestCase() {}
+    void initTestCase() {
+        if (!device) {
+            device = new QTouchDevice;
+            device->setType(QTouchDevice::TouchScreen);
+            QWindowSystemInterface::registerTouchDevice(device);
+        }
+    }
     void cleanupTestCase() {}
 
     void properties();
@@ -60,6 +68,7 @@ private slots:
 
 private:
     QQuickView *createAndShowView(const QString &file);
+    QTouchDevice *device;
 };
 
 void tst_QQuickMultiPointTouchArea::properties()
@@ -93,7 +102,7 @@ void tst_QQuickMultiPointTouchArea::signalTest()
     QPoint p4(80,100);
     QPoint p5(100,100);
 
-    QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas);
+    QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
 
     sequence.press(0, p1).press(1, p2).commit();
 
@@ -165,7 +174,7 @@ void tst_QQuickMultiPointTouchArea::nonOverlapping()
     QPoint p4(80,180);
     QPoint p5(100,180);
 
-    QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas);
+    QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
 
     sequence.press(0, p1).commit();
 
@@ -273,7 +282,7 @@ void tst_QQuickMultiPointTouchArea::nested()
     QPoint p2(40,100);
     QPoint p3(60,180);
 
-    QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas);
+    QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
 
     sequence.press(0, p1).commit();
 
@@ -455,30 +464,30 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
     QPoint p2(40,100);
 
     //moving one point vertically
-    QTest::touchEvent(canvas).press(0, p1);
+    QTest::touchEvent(canvas, device).press(0, p1);
     QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
 
     p1 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1);
+    QTest::touchEvent(canvas, device).move(0, p1);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1);
+    QTest::touchEvent(canvas, device).move(0, p1);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1);
+    QTest::touchEvent(canvas, device).move(0, p1);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1);
+    QTest::touchEvent(canvas, device).move(0, p1);
     QTest::mouseMove(canvas, p1);
 
     QVERIFY(flickable->contentY() < 0);
     QCOMPARE(point11->isValid(), false);
     QCOMPARE(point12->isValid(), false);
 
-    QTest::touchEvent(canvas).release(0, p1);
+    QTest::touchEvent(canvas, device).release(0, p1);
     QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
     QTest::qWait(50);
 
@@ -486,33 +495,33 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
 
     //moving two points vertically
     p1 = QPoint(20,100);
-    QTest::touchEvent(canvas).press(0, p1).press(1, p2);
+    QTest::touchEvent(canvas, device).press(0, p1).press(1, p2);
     QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
 
     QCOMPARE(point11->isValid(), true);
     QCOMPARE(point12->isValid(), true);
 
     p1 += QPoint(0,15); p2 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(0,15); p2 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(0,15); p2 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(0,15); p2 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     QVERIFY(flickable->contentY() < 0);
     QCOMPARE(point11->isValid(), false);
     QCOMPARE(point12->isValid(), false);
 
-    QTest::touchEvent(canvas).release(0, p1).release(1, p2);
+    QTest::touchEvent(canvas, device).release(0, p1).release(1, p2);
     QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
     QTest::qWait(50);
 
@@ -521,49 +530,49 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
     //moving two points horizontally, then one point vertically
     p1 = QPoint(20,100);
     p2 = QPoint(40,100);
-    QTest::touchEvent(canvas).press(0, p1).press(1, p2);
+    QTest::touchEvent(canvas, device).press(0, p1).press(1, p2);
     QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
 
     QCOMPARE(point11->isValid(), true);
     QCOMPARE(point12->isValid(), true);
 
     p1 += QPoint(15,0); p2 += QPoint(15,0);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(15,0); p2 += QPoint(15,0);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(15,0); p2 += QPoint(15,0);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(15,0); p2 += QPoint(15,0);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(0,15); p2 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(0,15); p2 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(0,15); p2 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     p1 += QPoint(0,15); p2 += QPoint(0,15);
-    QTest::touchEvent(canvas).move(0, p1).move(1, p2);
+    QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
     QTest::mouseMove(canvas, p1);
 
     QVERIFY(flickable->contentY() == 0);
     QCOMPARE(point11->isValid(), true);
     QCOMPARE(point12->isValid(), true);
 
-    QTest::touchEvent(canvas).release(0, p1).release(1, p2);
+    QTest::touchEvent(canvas, device).release(0, p1).release(1, p2);
     QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
     QTest::qWait(50);
 
index c4912c4..c34565e 100644 (file)
@@ -50,6 +50,8 @@
 class tst_QQuickPinchArea: public QObject
 {
     Q_OBJECT
+public:
+    tst_QQuickPinchArea() : device(0) { }
 private slots:
     void initTestCase();
     void cleanupTestCase();
@@ -60,9 +62,15 @@ private slots:
 
 private:
     QQuickView *createView();
+    QTouchDevice *device;
 };
 void tst_QQuickPinchArea::initTestCase()
 {
+    if (!device) {
+        device = new QTouchDevice;
+        device->setType(QTouchDevice::TouchScreen);
+        QWindowSystemInterface::registerTouchDevice(device);
+    }
 }
 
 void tst_QQuickPinchArea::cleanupTestCase()
@@ -220,17 +228,17 @@ void tst_QQuickPinchArea::scale()
     QPoint p1(80, 80);
     QPoint p2(100, 100);
 
-    QTest::touchEvent(canvas).press(0, p1, canvas);
-    QTest::touchEvent(canvas).stationary(0).press(1, p2, canvas);
+    QTest::touchEvent(canvas, device).press(0, p1, canvas);
+    QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
     p1 -= QPoint(10,10);
     p2 += QPoint(10,10);
-    QTest::touchEvent(canvas).move(0, p1,canvas).move(1, p2,canvas);
+    QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas);
 
     QCOMPARE(root->property("scale").toReal(), 1.0);
 
     p1 -= QPoint(10,10);
     p2 += QPoint(10,10);
-    QTest::touchEvent(canvas).move(0, p1,canvas).move(1, p2,canvas);
+    QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas);
 
     QCOMPARE(root->property("scale").toReal(), 1.5);
     QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
@@ -239,11 +247,11 @@ void tst_QQuickPinchArea::scale()
     // scale beyond bound
     p1 -= QPoint(50,50);
     p2 += QPoint(50,50);
-    QTest::touchEvent(canvas).move(0, p1, canvas).move(1, p2, canvas);
+    QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
 
     QCOMPARE(blackRect->scale(), 2.0);
 
-    QTest::touchEvent(canvas).release(0, p1, canvas).release(1, p2, canvas);
+    QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
 
     delete canvas;
 }
@@ -273,17 +281,17 @@ void tst_QQuickPinchArea::pan()
     QPoint p1(80, 80);
     QPoint p2(100, 100);
 
-    QTest::touchEvent(canvas).press(0, p1, canvas);
-    QTest::touchEvent(canvas).stationary(0).press(1, p2, canvas);
+    QTest::touchEvent(canvas, device).press(0, p1, canvas);
+    QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
     p1 += QPoint(10,10);
     p2 += QPoint(10,10);
-    QTest::touchEvent(canvas).move(0, p1, canvas).move(1, p2, canvas);
+    QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
 
     QCOMPARE(root->property("scale").toReal(), 1.0);
 
     p1 += QPoint(10,10);
     p2 += QPoint(10,10);
-    QTest::touchEvent(canvas).move(0, p1, canvas).move(1, p2, canvas);
+    QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
 
     QCOMPARE(root->property("center").toPointF(), QPointF(60, 60)); // blackrect is at 50,50
 
@@ -293,12 +301,12 @@ void tst_QQuickPinchArea::pan()
     // pan x beyond bound
     p1 += QPoint(100,100);
     p2 += QPoint(100,100);
-    QTest::touchEvent(canvas).move(0, p1, canvas).move(1, p2, canvas);
+    QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
 
     QCOMPARE(blackRect->x(), 140.0);
     QCOMPARE(blackRect->y(), 160.0);
 
-    QTest::touchEvent(canvas).release(0, p1, canvas).release(1, p2, canvas);
+    QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
 
     delete canvas;
 }
@@ -332,17 +340,17 @@ void tst_QQuickPinchArea::retouch()
     QPoint p1(80, 80);
     QPoint p2(100, 100);
 
-    QTest::touchEvent(canvas).press(0, p1, canvas);
-    QTest::touchEvent(canvas).stationary(0).press(1, p2, canvas);
+    QTest::touchEvent(canvas, device).press(0, p1, canvas);
+    QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
     p1 -= QPoint(10,10);
     p2 += QPoint(10,10);
-    QTest::touchEvent(canvas).move(0, p1, canvas).move(1, p2, canvas);
+    QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
 
     QCOMPARE(root->property("scale").toReal(), 1.0);
 
     p1 -= QPoint(10,10);
     p2 += QPoint(10,10);
-    QTest::touchEvent(canvas).move(0, p1, canvas).move(1, p2, canvas);
+    QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
 
     QCOMPARE(startedSpy.count(), 1);
 
@@ -355,17 +363,17 @@ void tst_QQuickPinchArea::retouch()
     QCOMPARE(startedSpy.count(), 1);
     QCOMPARE(finishedSpy.count(), 0);
 
-    QTest::touchEvent(canvas).stationary(0).release(1, p2, canvas);
+    QTest::touchEvent(canvas, device).stationary(0).release(1, p2, canvas);
 
     QCOMPARE(startedSpy.count(), 1);
     QCOMPARE(finishedSpy.count(), 0);
 
     QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 1);
 
-    QTest::touchEvent(canvas).stationary(0).press(1, p2, canvas);
+    QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
     p1 -= QPoint(10,10);
     p2 += QPoint(10,10);
-    QTest::touchEvent(canvas).move(0, p1, canvas).move(1, p2, canvas);
+    QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
 
     // Lifting and retouching results in onPinchStarted being called again
     QCOMPARE(startedSpy.count(), 2);
@@ -373,7 +381,7 @@ void tst_QQuickPinchArea::retouch()
 
     QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2);
 
-    QTest::touchEvent(canvas).release(0, p1, canvas).release(1, p2, canvas);
+    QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
 
     QCOMPARE(startedSpy.count(), 2);
     QCOMPARE(finishedSpy.count(), 1);