Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12.4, 5.13.0
-
None
Description
Example:
QML:
import QtQuick 2.12 import QtQuick.Window 2.12 Window { id: window visible: true width: 640 height: 480 title: qsTr("Binding Demo") ListView { id: viewItem model: ListModel { ListElement { val: 0 } ListElement { val: 1 } } property var currentValue : 0 // Changing the type to int will remove warning Binding { target: viewItem property: "currentValue" value: { return viewItem.model.get(viewItem.currentIndex).val } } Binding { target: viewItem property: "currentIndex" value: { return viewItem.indexByValue(viewItem.currentValue) } } function indexByValue(value) { for (var i = 0; i < viewItem.model.count; i++) { if (viewItem.model.get(i).val === value) { return i } } return -1 } } Timer { running: true interval: 2000 repeat: true onTriggered: viewItem.currentValue = ((viewItem.currentValue == 1) ? 0 : 1) } Text { y: 30 text: "currentValue: " + viewItem.currentValue } Text { y: 60 text: "currentIndex: " + viewItem.currentIndex } }
The following output appears when currentValue changes (timer triggers):
qrc:/main.qml:31:9: QML Binding: Binding loop detected for property "value"
Description
This warning seems to be wrong. Changing the type (for example to int) of currentValue lets the warning disappear, which is a strange behavior at first glance.
This only happens when using a ListModel in the binding.
viewItem.model.get(viewItem.currentIndex).val }
Workaround
I found no workaround.