Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
Pinch on a touchscreen

Table of Contents

In Dragging one DragHandler with one touchpoint we began with a detailed tour through the event delivery logic while one Rectangle is being dragged on a touchscreen with one finger. In Two touchpoints dragging two DragHandlers we looked at delivery of two touchpoints to drag two Rectangles. Now let's look at using two touchpoints to activate a PinchHandler on a parent Rectangle.

import QtQuick
Rectangle {
id: root
width: 400
height: 400
color: ph.active ? "aquamarine" : "beige"
PinchHandler {
id: ph
grabPermissions: PointerHandler.TakeOverForbidden
}
Rectangle {
objectName: "rect1"
x: 50
width: 100
height: 100
color: dh1.active ? "tomato" : "wheat"
DragHandler {
id: dh1
objectName: "dh1"
}
}
Rectangle {
objectName: "rect2"
x: 250
width: 100
height: 100
color: dh2.active ? "tomato" : "lightsteelblue"
DragHandler {
id: dh2
objectName: "dh2"
}
}
Rectangle {
objectName: "rect3"
x: 150
y: 150
width: 100
height: 100
color: dh3.active ? "tomato" : "darksalmon"
DragHandler {
id: dh3
objectName: "dh3"
}
}
}
pinch gesture on a touchscreen

Pinch gesture on touchscreen

As we saw, it's possible for the user to drag two DragHandlers with two fingers. It's also possible to execute the pinch gesture with the same two fingers in slightly different positions. Qt Quick acts like a distributed gesture recognizer when delivering multi-touch events: each pointer handler only tries to recognize one kind of gesture, but now let's look at a somewhat conflicting situation to see how the gesture gets disambiguated.

TODO diagrams and description

There's also a completely independent way that a pinch gesture can be delivered: as a QNativeGestureEvent. Find out more about that here: Native pinch gesture on a touchpad