QML:
动态创建对象
动态删除对象(不要试图手动删除由Repeater或者Loader创建的实例)
application.qml | SelfDestroyingRect.qml |
}
手工切换元素状态:
Rectangle {
id: root;
states: [
State {
name: "minSize"
PropertyChanges {
target: hideButtonLabel
text: ">"
}
PropertyChanges {
target: root
width: 10;
}
}
]
transitions: [
Transition {
NumberAnimation { target: root; property: "width"; duration: 200; easing.type: Easing.InOutQuad }
}
]
MouseArea {
anchors.fill: parent;
onClicked: {
if(root.state == '') {
root.state = "minSize"
} else {
root.state = ''
}
}
}
}