QML Loader: Binding loop detected for property "sourceComponent" in ComboBox
-
Hello everyone,
I have problem with binding loop in ComboBox. When I open popup and the TextInput with focus is loaded, then a get message
qrc:/qml/main.qml:48:22: QML Loader: Binding loop detected for property "sourceComponent" in Application Output.
The TextInput and Text change is necessary, because TextInput doesn't have property elide.
Here is my code:import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.12 ComboBox { id: cbx editable: true Component { id: textInputEditable TextInput { text: "aaa" horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter focus: true onActiveFocusChanged: { if ( !cbx.popup.opened ) { cbx.popup.open() } } } } Component { id: textRO Text { text: cbx.currentText horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter elide: Text.ElideMiddle } } contentItem: Loader { sourceComponent: cbx.popup.opened ? textInputEditable : textRO } model: ListModel { id: model ListElement { text: "Banana" } ListElement { text: "Apple" } ListElement { text: "Coconut" } } }
Do You have any idea how to avoid binding loop?
Thank You for Your help.
Vaclav. -
@LeLev said in QML Loader: Binding loop detected for property "sourceComponent" in ComboBox:
onDownChanged: loader.sourceComponent = down ? textInputEditable : textRO
It works. Thanks a lot.
Vaclav. -
Hello everyone,
I have problem with binding loop in ComboBox. When I open popup and the TextInput with focus is loaded, then a get message
qrc:/qml/main.qml:48:22: QML Loader: Binding loop detected for property "sourceComponent" in Application Output.
The TextInput and Text change is necessary, because TextInput doesn't have property elide.
Here is my code:import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.12 ComboBox { id: cbx editable: true Component { id: textInputEditable TextInput { text: "aaa" horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter focus: true onActiveFocusChanged: { if ( !cbx.popup.opened ) { cbx.popup.open() } } } } Component { id: textRO Text { text: cbx.currentText horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter elide: Text.ElideMiddle } } contentItem: Loader { sourceComponent: cbx.popup.opened ? textInputEditable : textRO } model: ListModel { id: model ListElement { text: "Banana" } ListElement { text: "Apple" } ListElement { text: "Coconut" } } }
Do You have any idea how to avoid binding loop?
Thank You for Your help.
Vaclav. -
@LeLev said in QML Loader: Binding loop detected for property "sourceComponent" in ComboBox:
onDownChanged: loader.sourceComponent = down ? textInputEditable : textRO
It works. Thanks a lot.
Vaclav.