summaryrefslogtreecommitdiffstats
path: root/examples/declarative/touchinteraction/gestures/experimental-gestures.qml
blob: cb190ea0ee9e336253279bb7bb87fd9efd68cce0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Qt 4.7
import Qt.labs.gestures 1.0

// Only works on platforms with Touch support.

Rectangle {
    id: rect
    width: 320
    height: 180

    Text {
        anchors.centerIn: parent
        text: "Tap / TapAndHold / Pan / Pinch / Swipe\nOnly works on platforms with Touch support."
        horizontalAlignment: Text.Center
    }

    GestureArea {
        anchors.fill: parent
        focus: true

        // Only some of the many gesture properties are shown. See Gesture documentation.

        onTap:
            console.log("tap pos = (",gesture.position.x,",",gesture.position.y,")")
        onTapAndHold:
            console.log("tap and hold pos = (",gesture.position.x,",",gesture.position.y,")")
        onPan:
            console.log("pan delta = (",gesture.delta.x,",",gesture.delta.y,") acceleration = ",gesture.acceleration)
        onPinch:
            console.log("pinch center = (",gesture.centerPoint.x,",",gesture.centerPoint.y,") rotation =",gesture.rotationAngle," scale =",gesture.scaleFactor)
        onSwipe:
            console.log("swipe angle=",gesture.swipeAngle)
        onGesture:
            console.log("gesture hot spot = (",gesture.hotSpot.x,",",gesture.hotSpot.y,")")
    }
}