【发布时间】:2015-08-26 07:20:18
【问题描述】:
我想根据条件加载主窗口:
Loader {
source: blocky ? "BlockyMainWindow.qml" : "RoundyMainWindow.qml"
}
但是要绑定的属性是一样的:width/height、anchors、transform。
仅当所有内容都写入onLoaded 处理程序时才有效。此外,您必须编写两次:一次执行Qt.binding,第二次仅分配值,因为如果不更改某些值,绑定将无法启动。
属性:
width: ContentOrientation.rotated ? parent.height : parent.width
height: ContentOrientation.rotated ? parent.width : parent.height
anchors.left: parent.left
anchors.top: ContentOrientation.rotated ? parent.bottom : parent.top
transform: Rotation { origin.x: 0; origin.y: 0; angle: ContentOrientation.rotated ? -90 : 0 }
如何让它变得简单?
【问题讨论】:
-
你能显示这些你正在绑定的相同属性吗?