Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Flickable doesn't scroll properly
Forum Updated to NodeBB v4.3 + New Features

QML Flickable doesn't scroll properly

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    super33
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved