[Interest] Why is this a binding loop?
Nuno Santos
nunosantos at imaginando.pt
Wed Nov 16 08:52:34 CET 2016
Binding loops sucks, but with some refactoring we always get to an alternative.
Try this:
Rectangle {
width: parent.width
height: label.paintedHeight*2
Text {
id: label
text: “title
anchors.centerIn: parent
}
}
If the binding loops persists maybe the dependency is being caused by anchors.centerIn: parent
Nuno
> On 16 Nov 2016, at 07:41, Elvis Stansvik <elvstone at gmail.com> wrote:
>
> Den 15 nov. 2016 11:15 em skrev "Jason H" <jhihn at gmx.com <mailto:jhihn at gmx.com>>:
> >
> > 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?
>
> I would think so too, but perhaps there's a limitation such that when you use childrenRect in the height expression, a dependency on that property group as a whole (including x and y, which are in turn dependent on the parent height, thus creating a "false" loop) is introduced.
>
> Though I don't know, that seems like a serious limitation to me, so I'm probably wrong. Just an idea.
>
> Does it work if you give the Text an id, and use the Text's height explicitly instead of childrenRect.height? (on the bus, so can't test).
>
> Elvis
>
> > _______________________________________________
> > Interest mailing list
> > Interest at qt-project.org <mailto:Interest at qt-project.org>
> > http://lists.qt-project.org/mailman/listinfo/interest <http://lists.qt-project.org/mailman/listinfo/interest>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161116/ecdf9434/attachment.html>
More information about the Interest
mailing list