diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-11-29 01:03:31 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-11-29 01:03:31 (GMT) |
commit | 6258fc281f5b66b2634b81a2633b117165cea7ef (patch) | |
tree | b74274051dd160652c00c674bc4a25fe6309735d /examples/declarative/touchinteraction | |
parent | 031ab2136c632d582a324941798be9e37825d287 (diff) | |
download | Qt-6258fc281f5b66b2634b81a2633b117165cea7ef.zip Qt-6258fc281f5b66b2634b81a2633b117165cea7ef.tar.gz Qt-6258fc281f5b66b2634b81a2633b117165cea7ef.tar.bz2 |
Add an example of using PinchArea.
Task-number: QTBUG-15491
Diffstat (limited to 'examples/declarative/touchinteraction')
-rw-r--r-- | examples/declarative/touchinteraction/pincharea/flickresize.qml | 50 | ||||
-rw-r--r-- | examples/declarative/touchinteraction/pincharea/qt-logo.jpg | bin | 0 -> 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 Binary files differnew file mode 100644 index 0000000..4014b46 --- /dev/null +++ b/examples/declarative/touchinteraction/pincharea/qt-logo.jpg |