[Interest] Why is this a binding loop?

Jason H jhihn at gmx.com
Wed Nov 16 14:19:14 CET 2016


> Il 15/11/2016 23:15, Jason H ha scritto:
> > Rectangle {
> > 	width: parent.width
> > 	height: childrenRect.height * 2
> > 	Text {
> > 		text: "title"
> > 		anchors.centerIn: parent
> > 	}
> > }
> > 
> > 'QML Rectangle: Binding loop detected for property "height"'
> > 
> > I think that computation should be possible without creating a binding loop?
> 
> * The height of the Rectangle depends on the size + the position of the
> children
> 
> * The position of the Text child depends on the size of the parent,
> therefore it depends on the height of the parent
> 
> Hence you've got a binding loop.

Well, yeah. I guess there is some ambiguity of childrenRect. I'd figure it's the bounding rect of the union of all the child areas, then offset x,y. So using this reasoning, x,y, might not always be zero, but if childrenRect is including the offset, then the x,y can only ever be zero, and we get a binding loop.

Here's what the docs say:
"""childrenRect group
childrenRect.x : real
childrenRect.y : real
childrenRect.width : real
childrenRect.height : real

This property holds the collective position and size of the item's children.
This property is useful if you need to access the collective geometry of an item's children in order to correctly size the item."""

It's probably too late to change it, but I'm wondering if someone can elaborate on why childrenRect.[width|height] includes the offset? It seems that it would be useful to provide a parameter that provides the offset unapplied to the rect.






More information about the Interest mailing list