Property Binding

属性绑定后会自动更新

Rectangle {
    otherItem.width
    height: otherItem.height
}

Rectangle {
    function calculateMyHeight() {
        return Math.max(otherItem.height, thirdItem.height);
    }

    anchors.centerIn: parent
    Math.min(otherItem.width, 10)
    height: calculateMyHeight()
    color: { if (width > 10) "blue"; else "red" }
}

Changing Bindings

Rectangle {
    id: rectangle
    otherItem.width
    height: otherItem.height

    states: State {
        name: "square"
        PropertyChanges {
            target: rectangle
            otherItem.height
        }
    }
}

Binding Element

Binding {
    target: system
    property: "brightness"
    value: slider.value
}

原文地址:https://www.cnblogs.com/cute/p/2139679.html