PinchArea and Zoom in QMl

  • Hi friends,

    I need some guidance on the pinchArea and zoom.i loaded an image on the window and a small circle on it at the center..using pinchArea i need to pinch and zoom that circle so that the image gets zoomed in..i am struggling to complete this task..please help me with some my code is as follows:

    @ property url sepImage: "qrc:/Images/CircuitBoard.png"
    Flickable {
    id: flick
    anchors.fill: parent

        Image {
            anchors.fill: parent
            source: sepImage
            fillMode: Image.PreserveAspectCrop
        Rectangle {
            id: pinchrect
            width: 100
            height: 100
            radius: 50
            color :"transparent"
            border.color: "blue"
            border.width: 2
            MouseArea {
                id: mousearea
                anchors.fill: parent
                drag.axis:  Drag.XAndYAxis
                drag.minimumX: 0
                drag.minimumY: 0
                drag.maximumX: flick.width - pinchrect.width
                drag.maximumY: flick.height - pinchrect.height
         PinchArea {
            id: pinchArea
            onPinchStarted: {
                         // i need to do something here to complete task..
            onPinchFinished: {               
                         // i need to do something here to complete 

  • Moderators

  • hi
    Thank u so much..that was very much helpful..But in that example insite the rectangle an image is put and used pinch and drag...That was working for me...But my reuirement is on the image i need to draw one circle and up on the drag and pinch of that circle only an image has to be zoomed..

    Thanks for ur help :-)

  • Moderators

    So how about setting to that circle.

  • if i do that only that circle gets enlarged..i could not zoom image

  • Moderators

    Well then i guess using onPinchStarted or onPinchUpdated you get pinch.scale and set it to the Image's scale property.

  • Well i will try that and meantime can we set for 2 objects

  • Moderators

    No i guess, last one will override.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.