QML TextArea & ScrollBar Binding loop
-
wrote on 3 Mar 2023, 09:31 last edited by
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.
-
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.
wrote on 9 Mar 2023, 21:15 last edited byI 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/2