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. ScrollView Binding Loop
Qt 6.11 is out! See what's new in the release blog

ScrollView Binding Loop

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 2.0k Views 2 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.
  • K Offline
    K Offline
    krobinson
    wrote on last edited by
    #1

    I am trying to create a zoom control using the ScrollView. Under normal conditions I want the content of the ScrollView to be the same size as the container. Then when you zoom in, I want the contents to be the size * 2. This will give you a bigger size content that you can scroll to see.

    Item
    {
    id: container
    anchors.fill: parent

    ScrollView
    {
        anchors.fill: parent
    
        Rectangle
        {
            height: surfaceContainer.height
            width: surfaceContainer.width
        }
    }
    

    }

    The problem is this causes a binding loop.
    qrc:/Qml/CustomScrollView.qml:322:9: QML ScrollViewHelper: Binding loop detected for property "horizontalScrollbarOffset"
    file:///C:/Qt/5.5/msvc2013/qml/QtQuick/Controls/Private/ScrollViewHelper.qml:124:5: QML ScrollBar: Binding loop detected for property "height"

    I tracked it down to this code in the ScrollViewer

    property int horizontalScrollbarOffset: horizontalScrollBar.visible && !horizontalScrollBar.isTransient ?
    horizontalScrollBar.height + scrollBarSpacing : 0

    It seems like it uses the scroll bar height to figure out the offset which causes the loop. If I take this out it works fine, but then it resets the scroll position every time.

    Is there any good way to get around this? Is there another control I could use instead of doing it this way.

    p3c0P 1 Reply Last reply
    0
    • K krobinson

      I am trying to create a zoom control using the ScrollView. Under normal conditions I want the content of the ScrollView to be the same size as the container. Then when you zoom in, I want the contents to be the size * 2. This will give you a bigger size content that you can scroll to see.

      Item
      {
      id: container
      anchors.fill: parent

      ScrollView
      {
          anchors.fill: parent
      
          Rectangle
          {
              height: surfaceContainer.height
              width: surfaceContainer.width
          }
      }
      

      }

      The problem is this causes a binding loop.
      qrc:/Qml/CustomScrollView.qml:322:9: QML ScrollViewHelper: Binding loop detected for property "horizontalScrollbarOffset"
      file:///C:/Qt/5.5/msvc2013/qml/QtQuick/Controls/Private/ScrollViewHelper.qml:124:5: QML ScrollBar: Binding loop detected for property "height"

      I tracked it down to this code in the ScrollViewer

      property int horizontalScrollbarOffset: horizontalScrollBar.visible && !horizontalScrollBar.isTransient ?
      horizontalScrollBar.height + scrollBarSpacing : 0

      It seems like it uses the scroll bar height to figure out the offset which causes the loop. If I take this out it works fine, but then it resets the scroll position every time.

      Is there any good way to get around this? Is there another control I could use instead of doing it this way.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @krobinson Try updating those properties by assignment i.e using = when height or width change signal handler.

      157

      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