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
Native pinch gesture on a touchpad

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 qq-ideal-pointer-event-delivery-parallel-drags we looked at delivery of two touchpoints to drag two Rectangles. In Pinch on a touchscreen we looked at delivery of two touchpoints to one Rectangle with a PinchHandler. Now let's look at how a native gesture event from a touchpad can activate the same PinchHandler.

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"
}
}
}

Native pinch gesture on touchpad

Touchpads generally do not send QTouchEvents with discrete QEventPoints: rather, the operating system does the gesture recognition ahead of time, and the raw touchpoints are not available. Qt delivers a QNativeGestureEvent representing the entire gesture, with only one QEventPoint: the mouse cursor position where the gesture is perceived to occur on the screen. For such events (and also for QWheelEvents and a few other simple ones), so far we use simpler (more ideal) delivery logic: there's no need for distributed gesture recognition, no need for filtering, no synthesis, and little ambiguity about which handler can handle a particular gesture.

TODO diagrams for deliverSinglePointEventUntilAccepted()