Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    FlickableY not 0 when at the top

    QML and Qt Quick
    1
    2
    1251
    Loading More Posts
    • 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.
    • J
      j_berry last edited by

      I've been trying to create a scroll bar, and come across this issue

      I have a ListView with 'boundsBehavior: "StopAtBounds"', and I am logging its contentY
      Its model refers to an external data source, which can be refreshed to check if it has changed.
      On the first load it behaves as expected, when at the top of the list the contentY is 0
      But after a refresh the top of the list has a much larger contentY
      However the flickable will still not allow me to scroll off the top of the list, back to 0, so it obviously knows where the content is.
      contentHeight also works as expected.

      Has anyone come across anything like this before? Is there a way to send the content back to 0?
      Or is there a way to get the value of contentY at the top of the list, so I can use it as some kind of offset on my scroll bar?

      Thanks for your help

      1 Reply Last reply Reply Quote 0
      • J
        j_berry last edited by

        I've done a bit more searching and found that what I should be using is positionViewAtIndex() (http://doc.qt.nokia.com/latest/qml-listview.html#positionViewAtIndex-method ), which I would need to call whenever the position of the scrollbar changes.

        @
        onNewFlickablePositionChanged:
        {
        console.log("new flickablePosition = " + newFlickablePosition)
        flickable.positionViewAtIndex(newFlickablePosition, ListView.Beginning)
        }
        @

        But using the index of the item is not compatible with the continuous scrolling of the scroll bar, and I would like to use the scrollbar on any flickable, not just a list.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post