我有一个 QML 菜单组件,我想将其放置在我的每个视图的顶部并进行某种同步,以便它具有典型网页菜单的外观。请问我该怎么做
import QtQuick 1.0
Row {
width: 500
height: 50
anchors.centerIn: parent
spacing: parent.width/6
Button {
id: loadButton
text: qsTr("Menu")
}
Button {
id: saveButton
text: qsTr("Profile")
}
Button {
id: exitButton
text: qsTr("View Products")
}
}
原文由 Kobojunkie 发布,翻译遵循 CC BY-SA 4.0 许可协议
阅读“z”属性 QDeclarativeItem 或 QML Item。答案是为您的菜单组件实例提供最高的 z 值。
qml 渲染器根据这个值决定首先绘制哪些项目;如果有东西覆盖你的菜单,它会在它下面结束。顺便说一句,默认的 z 值是 0,所以它们都是一样的,而且它或多或少是未定义的渲染顺序。
祝你好运!