QML PinchArea not working
Unsolved
Mobile and Embedded
-
Hello,
I am trying to make an image zoomable via PinchArea and can't find a way to do it. I log the onPinchStarted and onPinchUpdated events, but they never fire.
Here is image and pinch area (the source and visibility is set via timer):
Image { id: mainimage visible: false source: "" fillMode: Image.PreserveAspectFit width: column.width; z: 10 PinchArea { id: imagepinch width: mainimage.width height: mainimage.height pinch.target: mainimage pinch.minimumScale: 1.0 pinch.maximumScale: 5.0 pinch.dragAxis: Pinch.XAndYAxis anchors.fill: parent z: 20 onPinchStarted: { console.log("started"); } onPinchUpdated: { console.log(pinch); } } }
Here is the timer that sets the source:
Timer { id: checktimer interval: 1000 running: true repeat: true onTriggered: { if(jsondata) { checktimer.running = false; loadinglabel.visible = false; json_o = JSON.parse(jsondata); jsondata = ""; mainimage.source = json_o.src; mainimage.visible = true; imagepinch.height = mainimage.height; var koef = mainimage.width / json_o.width; var h = koef * json_o.height; mainimage.height = h; imagepinch.height = h; console.log(imagepinch.x,imagepinch.y); } } }
-
Try moving your pincharea outside of the image you are scaling. Either wrap the image inside the pincharea or keep them as siblings. I avoid putting things like pincharea and mouseareas inside things i am scaling as it can really mess with your x,y cordinates on click/select events as things scale.