PinchHandler QML Type▲
-
Import Statement: import QtQuick 2.12
-
Inherits: MultiPointHandler
-
Group: PinchHandler is part of qtquick-input-handlers
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
) +
"%"
}
}
The pinch begins when the number of fingers pressed is between minimumPointCount and maximumPointCount, inclusive. Until then, PinchHandler tracks the positions of any pressed fingers, but if it's a disallowed number, it does not scale or rotate its