summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-11-29 01:03:31 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-11-29 01:03:31 (GMT)
commit6258fc281f5b66b2634b81a2633b117165cea7ef (patch)
treeb74274051dd160652c00c674bc4a25fe6309735d /examples
parent031ab2136c632d582a324941798be9e37825d287 (diff)
downloadQt-6258fc281f5b66b2634b81a2633b117165cea7ef.zip
Qt-6258fc281f5b66b2634b81a2633b117165cea7ef.tar.gz
Qt-6258fc281f5b66b2634b81a2633b117165cea7ef.tar.bz2
Add an example of using PinchArea.
Task-number: QTBUG-15491
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/touchinteraction/pincharea/flickresize.qml50
-rw-r--r--examples/declarative/touchinteraction/pincharea/qt-logo.jpgbin0 -> 40886 bytes
2 files changed, 50 insertions, 0 deletions
diff --git a/examples/declarative/touchinteraction/pincharea/flickresize.qml b/examples/declarative/touchinteraction/pincharea/flickresize.qml
new file mode 100644
index 0000000..8034e29
--- /dev/null
+++ b/examples/declarative/touchinteraction/pincharea/flickresize.qml
@@ -0,0 +1,50 @@
+import QtQuick 1.1
+
+Rectangle {
+ width: 640
+ height: 360
+ color: "gray"
+
+ Flickable {
+ id: flick
+ anchors.fill: parent
+ contentWidth: 500
+ contentHeight: 500
+
+ PinchArea {
+ width: Math.max(flick.contentWidth, flick.width)
+ height: Math.max(flick.contentHeight, flick.height)
+ onPinchChanged: {
+ // adjust content pos due to drag
+ flick.contentX += pinch.lastCenter.x - pinch.center.x
+ flick.contentY += pinch.lastCenter.y - pinch.center.y
+
+ // resize content
+ var scale = 1.0 + pinch.scale - pinch.lastScale
+ flick.resizeContent(flick.contentWidth * scale, flick.contentHeight * scale, pinch.center)
+ }
+
+ onPinchFinished: {
+ // Move its content within bounds.
+ flick.returnToBounds()
+ }
+
+ Rectangle {
+ width: flick.contentWidth
+ height: flick.contentHeight
+ color: "white"
+ Image {
+ anchors.fill: parent
+ source: "qt-logo.jpg"
+ MouseArea {
+ anchors.fill: parent
+ onDoubleClicked: {
+ flick.contentWidth = 500
+ flick.contentHeight = 500
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/touchinteraction/pincharea/qt-logo.jpg b/examples/declarative/touchinteraction/pincharea/qt-logo.jpg
new file mode 100644
index 0000000..4014b46
--- /dev/null
+++ b/examples/declarative/touchinteraction/pincharea/qt-logo.jpg
Binary files differ