On 16 Nov. 2016 21:19, "Jason H" <jh...@gmx.com> wrote: > > > 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.
I'm guessing it's because childrenRect is a QRect, which is a structure that has always contained info about the position (offset) and size (width & height) of a rectangle. The related data structure that omits the position/offset is QSize. Perhaps an additional property for Item might be useful? I can't think of a good name for it though. (For consistency and non-ambiguity, the name for such a property should not contain the term "rect") Regards, Sze-Howe
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest