Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QML ScrollView binding loop for "contentHeight"



  • Binding loops with scroll views seem to be a popular topic. However, I couldn't solve this issue with the existing posts I found. I'm getting the error:

    QML ScrollView: Binding loop detected for property "contentHeight"
    

    when I'm doing the following in my Qml file:

    ScrollView {
               id: scrollView
               width: 1480
               height: 197
               font.pointSize: 14
               clip: true
               ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
    
               ListView {
                   id: logView
                   x: 20
                   y: 672
                   model: qros.rosLog
                   delegate: logDelegate
                   spacing: 5
               }
           }
    
           Component {
               id: logDelegate
    
               RowLayout {
                   Text {
                       Layout.maximumWidth: 1480
                       color: "#FFFFFF"
                       font.family: "Arial"
                       font.pointSize: 8
                       wrapMode: Text.WordWrap
                       text: modelData
                   }
               }
           }
    

    I don't see where this comes from since this looks like the example.



  • @prex Can you accomplish the same thing without a scrollview? I have found I can do the same with the version 2 of ListViews without scrollviews. YMMV.


  • Moderators

    @prex
    Give your Listview a width/height and the binding loop should go away.

    I assume, without hight/width set, it scales itself to its content and that trickers a contentHeight change of the scrollView



  • @J-Hilk Unfortunately, this didn't solve it. The GUI works fine until I start scrolling manually in the ScrollView, while new elements are added to the ListView.



  • @prex Can you accomplish the same thing without a scrollview? I have found I can do the same with the version 2 of ListViews without scrollviews. YMMV.



  • @fcarney Easy as that. This works perfectly fine with just a ListView. I added a ScrollBar to it and I have the same without any binding loops. Thanks!