Prevent Flickable from returning to bounds



  • Hi,

    I have set:

        boundsBehavior: Flickable.DragAndOvershootBounds
        boundsMovement: Flickable.FollowBoundsBehavior
    

    Although I never call returnToBounds, the flickable returns to bounds automatically when the user stops dragging or pinching. Is there a way to prevent that?

    Thanks
    Philippe.



  • @maitai_vw
    Are you sure you are defining your Flickable correctly? For instance, are you sure that
    your contentWidth and/or contentHeight are set to an appropriate size?

    In the example below the flicking works as expected (setting contentX allows you to flick both left and right):

            Flickable {
                id: flickable
                width: window.width
                height: window.height
                contentWidth: 2*window.width
                contentHeight: window.height
                contentX: window.width
    
                Rectangle {
                    color: "red"
                    width: window.width
                    height: window.height
                    x:  0
                }
    
                Rectangle {
                    color: "blue"
                    width: window.width
                    height: window.height
                    x:  window.width
                }
            }
    

    In the following example, contentWidth is just 1 pixel wider than the width of the
    flickable, so if you drag the flickable more than 1 pixel, it will return to its bounds,
    not matter what.

            Flickable {
                id: flickable
                width: window.width
                height: window.height
                contentWidth: window.width + 1
                contentHeight: window.height
                contentX: 0
                boundsBehavior: Flickable.DragOverBounds
    
                Rectangle {
                    color: "red"
                    width: window.width/2
                    height: window.height
                    x:  0
                }
    
                Rectangle {
                    color: "blue"
                    width: window.width/2
                    height: window.height
                    x:  window.width/2
                }
            }
    


  • @Diracsbracket Thanks for you reply
    I have tried that but this is not good in my case: I have an image in the flickable, and I set contentWidth and contentHeight to exactly the image sourceSize (at the beginning), so the user can zoom, pan, etc.

    If I start with let's say twice the size for the content I get an image zoomed from the beginning, of course.

    But your comment gave me an idea that seems to work: I added margins around the content and it looks like I achieve what I wanted (more test needed)

        flick.bottomMargin = flick.contentHeight / 2
        flick.topMargin = flick.contentHeight / 2
        flick.leftMargin = flick.contentWidth / 2
        flick.rightMargin = flick.contentWidth / 2
    

    Thanks !
    Philippe


Log in to reply
 

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