PinchHandler QML Type
Handler for pinch gestures. More...
Import Statement: | import QtQuick 2.12 |
Inherits: |
Properties
- active : bool
- activeScale : real
- centroid : QtQuick::HandlerPoint
- maximumRotation : real
- maximumScale : real
- maximumX : real
- maximumY : real
- minimumRotation : real
- minimumScale : real
- minimumTouchPoints : int
- minimumX : real
- minimumY : real
- rotation : real
- scale : real
- translation : QVector2D
Detailed Description
PinchHandler is a handler that interprets a multi-finger gesture to interactively rotate, zoom, and drag an Item. Like other Input Handlers, by default it is fully functional, and manipulates its target, which is the Item within which it is declared.
import QtQuick 2.12 Rectangle { width: 400 height: 300 color: "lightsteelblue" PinchHandler { } }
It has properties to restrict the range of dragging, rotation, and zoom.
If it is declared within one Item but is assigned a different target, it handles events within the bounds of the outer Item but manipulates the target
Item instead:
import QtQuick 2.12 Item { width: 640 height: 480 Rectangle { id: map color: "aqua" width: 400 height: 300 } PinchHandler { target: map } }
A third way to use it is to set target to null
and react to property changes in some other way:
import QtQuick 2.12 Item { width: 640 height: 480 PinchHandler { id: handler target: null } Text { color: handler.active ? "darkgreen" : "black" text: handler.rotation.toFixed(1) + " degrees\n" + handler.translation.x.toFixed(1) + ", " + handler.translation.y.toFixed(1) + "\n" + (handler.scale * 100).toFixed(1) + "%" } }
See also PinchArea.
Property Documentation
active : bool |
This property is true when all the constraints (epecially minimumTouchPoints) are satisfied and the target, if any, is being manipulated.
[read-only] activeScale : real |
The scale factor while the pinch gesture is being performed. It is 1.0 when the gesture begins, increases as the touchpoints are spread apart, and decreases as the touchpoints are brought together. If target is not null, its scale will be automatically multiplied by this value. Otherwise, bindings can be used to do arbitrary things with this value.
[read-only] centroid : QtQuick::HandlerPoint |
A point exactly in the middle of the currently-pressed touch points. The target will be rotated around this point.
maximumX : real |
The maximum acceptable x coordinate of the centroid
maximumY : real |
The maximum acceptable y coordinate of the centroid
minimumTouchPoints : int |
The pinch begins when this number of fingers are pressed. Until then, PinchHandler tracks the positions of any pressed fingers, but if it's an insufficient number, it does not scale or rotate its target, and the active property will remain false.
minimumX : real |
The minimum acceptable x coordinate of the centroid
minimumY : real |
The minimum acceptable y coordinate of the centroid
[read-only] rotation : real |
[read-only] scale : real |
The scale factor that will automatically be set on the target if it is not null. Otherwise, bindings can be used to do arbitrary things with this value. While the pinch gesture is being performed, it is continuously multiplied by activeScale; after the gesture ends, it stays the same; and when the next pinch gesture begins, it begins to be multiplied by activeScale again.
The translation of the gesture centroid. It is (0, 0)
when the gesture begins.