Nominate our 2022 Qt Champions!

QML PinchArea not working

  • 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.minimumScale: 1.0
                    pinch.maximumScale: 5.0
                    pinch.dragAxis: Pinch.XAndYAxis
                    anchors.fill: parent
                    z: 20
                    onPinchStarted: {
                    onPinchUpdated: {

    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;

  • 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.

Log in to reply