PDA

View Full Version : Strange binding error in Flow element



sedi
28th April 2017, 18:39
Hi,

I receive a strange binding error that I don't understand. The output seems to work as expected. By commenting out unnessecary stuff I've tracked it down to this minimal example:


Flow {
height: visible ? childrenRect.height : 0
Repeater {
model: [my model]
delegate: CheckBox {
}
}
}

That gives me
QML Flow: Binding loop detected for property "height"

Please note: if I change height property to
height: childrenRect.height (thus removing the ternary operator), the error does not occur. That especially leaves me puzzled.

Any ideas?

high_flyer
1st May 2017, 22:37
Its seems that you have, just as the error states, a recursive property binding.
That means, that one height property effects the other, and the other is bound to the first, causing an infinite loop of setting values between the to height properties.

sedi
12th May 2017, 21:00
I don't know how this can be a binding error, but of course you are right. Actually, the solution is quite simple after all: I define a bool property in the parent item and let both visible and height reference to it:


property bool flowVisible: true
Flow {
visible: flowVisible
height: flowVisible? childrenRect.height : 0
Repeater {
model: [my model]
delegate: CheckBox {
}
}
}


Thanks!