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
- minimumRotation : real
- minimumScale : real
- minimumTouchPoints : int
- rotation : real
- scale : real
- translation : QVector2D
- xAxis
- xAxis.minimum : real
- xAxis.maximum : real
- xAxis.enabled : bool
- yAxis
- yAxis.minimum : real
- yAxis.maximum : real
- yAxis.enabled : bool
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.
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.
[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.
xAxis
controls the constraints for horizontal translation of the target item.
minimum
is the minimum acceptable x coordinate of the translation. maximum
is the maximum acceptable x coordinate of the translation. If enabled
is true, horizontal dragging is allowed.
yAxis
controls the constraints for vertical translation of the target item.
minimum
is the minimum acceptable y coordinate of the translation. maximum
is the maximum acceptable y coordinate of the translation. If enabled
is true, vertical dragging is allowed.
© 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.