QML Flickable doesn't scroll properly



  • I am a beginner in QML, so I apologize if this seems like an obvious question. I am trying to make a simple browser and I have put the WebView inside the Flickable. But the problem is when I drag the WebView within the flickable to scroll, it just bounces back to its original position. My code looks like this:
    import QtQuick 1.1
    import QtWebKit 1.0

    Rectangle
    {
    id: windowcontainer
    width: 1024
    height: 768

    @ Rectangle
    {
    id: controlscontainer
    width: parent.width
    height: 40
    color: "#1478ca"

        Rectangle
        {
            id: urlcontainer
            x: 8
            y: 10
            width: controlscontainer.width-100
            height: 20
    
            TextEdit
            {
                id: urlbox
                width: urlcontainer.width
                height: urlcontainer.height
                text: web_view.url
    
                Keys.onReturnPressed:
                {
                    web_view.url = urlbox.text
                }
    
            }
         }
    }
    
    Rectangle
    {
        id: webcontainer
        x: 0
        y: 40
        width: windowcontainer.width
        height: 416
    
        Flickable
        {
            id: viewcontainer
            interactive: true
            width: web_view.height
            height: web_view.height
            contentHeight: web_view.preferredHeight
            contentWidth: web_view.preferredWidth
            boundsBehavior: Flickable.DragOverBounds
    
            WebView
            {
                id: web_view
                url: "http://www.google.com/"
                preferredWidth: webcontainer.width
                preferredHeight: webcontainer.height
            }
        }
    }
    

    }@

    Is there anyway I can fix this? Any help would be appreciated. Thank in advance!



  • There is a contradiction in your webcontainer item.

    You say that the content height of your flickable is equal to the web_view height. And you say that the web_view height is equal to the webcontainer height. The only way to interpret this is that the flickable contentArea has the same height as its parent which should in exactly the behaviour you describe. I suspect it will work if you don't explicitly override the preferred height of the web_view


Log in to reply
 

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