flickresize.qml Example File
touchinteraction/pincharea/flickresize.qml
import QtQuick 2.0
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)
property real initialWidth
property real initialHeight
onPinchStarted: {
initialWidth = flick.contentWidth
initialHeight = flick.contentHeight
}
onPinchUpdated: {
flick.contentX += pinch.previousCenter.x - pinch.center.x
flick.contentY += pinch.previousCenter.y - pinch.center.y
flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center)
}
onPinchFinished: {
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
}
}
}
}
}
}
}