[Interest] Resolving QML binding loops?

Cornelius Hald hald at icandy.de
Wed Jan 8 13:10:59 CET 2014


Hi,

I was wondering if there are general patterns or best practices on how
to omit/resolve QML binding loops.

For example, the following code does what it should do, but while
resizing the window I get a lot of warnings about the binding loop.

Rectangle {
    property double ratio: width / height
    width: 600
    height: 300
    color: "gray"

    // Rectangle with a fixed aspect ratio centered in parent
    Rectangle {
        property double ratio: 1.6
        color: "red"
        height: parent.ratio < ratio ? width / ratio : parent.height
        width: parent.ratio > ratio ? height * ratio : parent.width
        anchors.centerIn: parent
    }
}

How do others solve issues like this?

Cheers,
Conny





More information about the Interest mailing list