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 <elvst...@gmail.com> wrote:
> 
> Den 15 nov. 2016 11:15 em skrev "Jason H" <jh...@gmx.com 
> <mailto:jh...@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@qt-project.org <mailto:Interest@qt-project.org>
> > http://lists.qt-project.org/mailman/listinfo/interest 
> > <http://lists.qt-project.org/mailman/listinfo/interest>
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to