QT属性绑定binging

版权声明:如果对您有帮助,求点赞!本文为博主原创作品,转载请声明出处! https://blog.csdn.net/u011086209/article/details/86609578
Item {
    width: 500
    height: 500

    Rectangle {
        id: rect
        width: 100
        color: "yellow"
    }

    Component.onCompleted: {
        rect.height = Qt.binding(function() { return this.width * 2 })
        console.log("rect.height = " + rect.height) // prints 200, not 1000
    }
}

猜你喜欢

转载自blog.csdn.net/u011086209/article/details/86609578
今日推荐