【发布时间】:2012-05-28 20:49:43
【问题描述】:
在我的应用程序中,我在一个文件中定义了一个配置屏幕:“ConfigScreen.qml”。它包含状态,以及在它们之间定义的转换,以使其平滑地出现和消失:
Rectangle {
id: container
width: parent.width
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottomMargin: 5
state: "start"
states: [
State {
name: "start"
AnchorChanges { target: container; anchors.verticalCenter: undefined }
AnchorChanges { target: container; anchors.bottom: container.parent.top }
},
State {
name: "center"
AnchorChanges { target: container; anchors.bottom: undefined }
AnchorChanges { target: container; anchors.verticalCenter: container.parent.verticalCenter }
}
]
transitions: Transition {
AnchorAnimation { duration: 800; easing.type: Easing.InOutBack; easing.overshoot: 2 }
}
}
矩形进入场景并根据当前状态(设置在父级中的某个位置)使其离开。
现在我想创建更多视图(单独的文件),具有与上述相同的效果,但内容不同。如果将来需要对此效果进行一些更新,我想在一个地方进行更改,而不是在每个使用它的屏幕上进行更改。
这可以在 QML 中以某种方式完成吗?
【问题讨论】:
标签: qt qml extensibility