PinchArea zoom out



  • Hi;
    I'm working on that example:
    http://docs.huihoo.com/qt/5.x/qtquick-touchinteraction-pincharea-flickresize-qml.html
    and wonder how to prevent pinch scale <1. I dont want to zoom- out I want to keep scale
    <1,4>. So I added

    PinchArea {
                    width: Math.max(flick.contentWidth, flick.width)
                    height: Math.max(flick.contentHeight, flick.height)
                    pinch.minimumScale : 1
                    pinch.maximumScale : 4
    

    But still can zoom-out <1.



  • I solve it shomehow.
    1085 - is my minaimal width(scale) of picture below which user cant zoom out

                    onPinchUpdated: {
                        isSaleAllowed = !(initialWidth * pinch.scale < 1085)
    
                        if( isSaleAllowed )
                        {
                            // adjust content pos due to drag
                            flick.contentX += pinch.previousCenter.x - pinch.center.x
                            flick.contentY += pinch.previousCenter.y - pinch.center.y
    
                            // resize content
                            flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center)
                        }
                    }
    

    Documentation says:

    PinchArea can be used in two ways:
    setting a pinch.target to provide automatic interaction with an item
    using the onPinchStarted, onPinchUpdated and onPinchFinished handlers
    

    Probably

     pinch.minimumScale : 
     pinch.maximumScale :
    

    regards only to the first way.


Log in to reply
 

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