本例子使用Loader加载myComponent组件,然后通过Loader的item属性设置myComponent的value属性。
代码语言:javascript复制import QtQuick 2.0
Rectangle {
color: "gray"
anchors.fill: parent
property Component myComponent:
Rectangle {
property int value: 0
width: 100
height: 100
}
Loader {
id: loader
sourceComponent: myComponent
Component.onCompleted: loader.item.value = 100
}
}