summaryrefslogtreecommitdiffstats
path: root/examples/declarative/touchinteraction
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/touchinteraction')
-rw-r--r--examples/declarative/touchinteraction/gestures/experimental-gestures.qml36
-rw-r--r--examples/declarative/touchinteraction/gestures/gestures.qmlproject16
-rw-r--r--examples/declarative/touchinteraction/mousearea/mouse.qml47
-rw-r--r--examples/declarative/touchinteraction/mousearea/mousearea.qmlproject16
-rw-r--r--examples/declarative/touchinteraction/touchinteraction.qmlproject16
5 files changed, 131 insertions, 0 deletions
diff --git a/examples/declarative/touchinteraction/gestures/experimental-gestures.qml b/examples/declarative/touchinteraction/gestures/experimental-gestures.qml
new file mode 100644
index 0000000..cb190ea
--- /dev/null
+++ b/examples/declarative/touchinteraction/gestures/experimental-gestures.qml
@@ -0,0 +1,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,")")
+ }
+}
diff --git a/examples/declarative/touchinteraction/gestures/gestures.qmlproject b/examples/declarative/touchinteraction/gestures/gestures.qmlproject
new file mode 100644
index 0000000..d4909f8
--- /dev/null
+++ b/examples/declarative/touchinteraction/gestures/gestures.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/declarative/touchinteraction/mousearea/mouse.qml b/examples/declarative/touchinteraction/mousearea/mouse.qml
new file mode 100644
index 0000000..06134b7
--- /dev/null
+++ b/examples/declarative/touchinteraction/mousearea/mouse.qml
@@ -0,0 +1,47 @@
+import Qt 4.7
+
+Rectangle {
+ width: 200; height: 200
+
+ Rectangle {
+ width: 50; height: 50
+ color: "red"
+
+ Text { text: "Click"; anchors.centerIn: parent }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+ onPressed: console.log('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')')
+ onReleased: console.log('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')')
+ onClicked: console.log('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')')
+ onDoubleClicked: console.log('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')')
+ onPressAndHold: console.log('press and hold')
+ onEntered: console.log('entered ' + pressed)
+ onExited: console.log('exited ' + pressed)
+ }
+ }
+
+ Rectangle {
+ y: 100; width: 50; height: 50
+ color: "blue"
+
+ Text { text: "Drag"; anchors.centerIn: parent }
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: parent
+ drag.axis: Drag.XAxis
+ drag.minimumX: 0
+ drag.maximumX: 150
+
+ onPressed: console.log('press')
+ onReleased: console.log('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')')
+ onClicked: console.log('click' + '(wasHeld: ' + mouse.wasHeld + ')')
+ onDoubleClicked: console.log('double click')
+ onPressAndHold: console.log('press and hold')
+ }
+ }
+}
diff --git a/examples/declarative/touchinteraction/mousearea/mousearea.qmlproject b/examples/declarative/touchinteraction/mousearea/mousearea.qmlproject
new file mode 100644
index 0000000..d4909f8
--- /dev/null
+++ b/examples/declarative/touchinteraction/mousearea/mousearea.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/declarative/touchinteraction/touchinteraction.qmlproject b/examples/declarative/touchinteraction/touchinteraction.qmlproject
new file mode 100644
index 0000000..d4909f8
--- /dev/null
+++ b/examples/declarative/touchinteraction/touchinteraction.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}