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 TextArea & ScrollBar Binding loop
Forum Updated to NodeBB v4.3 + New Features

QML TextArea & ScrollBar Binding loop

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 981 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.
  • U Offline
    U Offline
    Uniformed6525
    wrote on 3 Mar 2023, 09:31 last edited by
    #1

    Hello,

    I'm trying to have a Rectangle resize vertically according to the height of a TextArea, while also capping the height to 120px.

    Here's the QML code:

    import QtQuick
    import QtQuick.Window
    import QtQuick.Controls 6.3
    
    Window {
        id: window
        width: 640
        height: 480
        visible: true
        color: "#1d1d1d"
        title: qsTr("Hello World")
    
        Rectangle {
            id: rectangle1
            height: Math.min(textArea.implicitHeight, 120)
            color: "#4b4b4b"
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.bottom: parent.bottom
            anchors.rightMargin: 16
            anchors.leftMargin: 16
            anchors.bottomMargin: 16
    
            ScrollView {
                id: scrollView
                anchors.fill: parent
                smooth: true
    
                TextArea {
                    id: textArea
                    wrapMode: Text.WordWrap
                    placeholderText: qsTr("Text Area")
                }
            }
        }
    }
    

    However, as the TextArea resizes, I get the following warning:

    QML TextArea: Binding loop detected for property "implicitHeight"
    

    A similar warning occurs when the rectangle hits its maximum height of 120px:

    QML ScrollBar: Binding loop detected for property "visible"
    

    Any ideas as to what is causing this binding loop is much appreciated.

    M 1 Reply Last reply 9 Mar 2023, 21:15
    0
    • U Uniformed6525
      3 Mar 2023, 09:31

      Hello,

      I'm trying to have a Rectangle resize vertically according to the height of a TextArea, while also capping the height to 120px.

      Here's the QML code:

      import QtQuick
      import QtQuick.Window
      import QtQuick.Controls 6.3
      
      Window {
          id: window
          width: 640
          height: 480
          visible: true
          color: "#1d1d1d"
          title: qsTr("Hello World")
      
          Rectangle {
              id: rectangle1
              height: Math.min(textArea.implicitHeight, 120)
              color: "#4b4b4b"
              anchors.left: parent.left
              anchors.right: parent.right
              anchors.bottom: parent.bottom
              anchors.rightMargin: 16
              anchors.leftMargin: 16
              anchors.bottomMargin: 16
      
              ScrollView {
                  id: scrollView
                  anchors.fill: parent
                  smooth: true
      
                  TextArea {
                      id: textArea
                      wrapMode: Text.WordWrap
                      placeholderText: qsTr("Text Area")
                  }
              }
          }
      }
      

      However, as the TextArea resizes, I get the following warning:

      QML TextArea: Binding loop detected for property "implicitHeight"
      

      A similar warning occurs when the rectangle hits its maximum height of 120px:

      QML ScrollBar: Binding loop detected for property "visible"
      

      Any ideas as to what is causing this binding loop is much appreciated.

      M Offline
      M Offline
      malocascio
      wrote on 9 Mar 2023, 21:15 last edited by
      #2

      I just ran into a similar problem. I had something like this:

      ScrollView {
          Layout.fillWidth: true
          Layout.fillHeight: true
          
          TextArea {
              text: "Something"
          }
      }
      

      And was seeing the QML ScrollBar: Binding loop detected for property "visible" error. I found these two bug reports, and the latter states that "We were fitting it in height and it was freaking out whenever the horizontal scrollbar appeared." So I just make the scrollbar stay on all the time, and now it seems fine:

      ScrollView {
          Layout.fillWidth: true
          Layout.fillHeight: true
          ScrollBar.vertical.policy: ScrollBar.AlwaysOn
          
          TextArea {
              text: "Something"
          }
      }
      

      I know that's not a fix, but I figured it was worth sharing.

      1 Reply Last reply
      2

      1/2

      3 Mar 2023, 09:31

      • Login

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