'Binding loop detected for property "text"
My implementation is to keep track of whether I have placed the dot already •
. I am trying to acheive the following: A • D • G • J • M • P • S • V • Z
. The property binding for check, somehow it doesn't want to go back to 0. I also tried using a local var, but it will always be 0 or 1. How can I resolve this? I get the following error: Binding loop detected for property "text"
import QtQuick 2.15
import QtQuick.Window 2.15
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Rectangle {
id: root
visible: true
anchors.fill: parent
property string letters: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
property int check: 0
readonly property real dx: 20
function midpoint(idx) {
return 20 + idx * root.dx;
}
function newLetters(index) {
if(root.letters[index] === "A"){
root.check = 0
return true
}
if(root.letters[index] === "D"){
root.check = 0
return true
}
if(root.letters[index] === "G"){
root.check = 0
return true
}
if(root.letters[index] === "J"){
root.check = 0
return true
}
if(root.letters[index] === "M"){
root.check = 0
return true
}
if(root.letters[index] === "P"){
root.check = 0
return true
}
if(root.letters[index] === "S"){
root.check = 0
return true
}
if(root.letters[index] === "V"){
root.check = 0
return true
}
if(root.letters[index] === "Z"){
root.check = 0
return true
}
else {
root.check = root.check + 1
}
}
Repeater {
model: 26
Text {
anchors.horizontalCenter: parent.left
anchors.horizontalCenterOffset: root.midpoint(index)
anchors.verticalCenter: parent.verticalCenter
text: root.newLetters(index) ? root.letters[index] : (root.check === 0 ? " • " : "")
}
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|