這些菜單默認顯示在左側。我想在菜單開始出現之前在左側放置一些文本。如何將菜單向右推以便為菜單欄中的文本創建空間?我想要以下內容:該文本“AmplifyRemote”出現在菜單啟動之前。這里如何實現呢?ApplicationWindow{ id: window; visible: true; width: Screen.width; height: Screen.height; flags: Qt.FramelessWindowHint menuBar: MenuBar { id: menuBar Menu { title: qsTr("File") } Menu { title: qsTr("Edit") } Menu { title: qsTr("View") } Menu { title: qsTr("Help") } delegate: MenuBarItem { id: menuBarItem font { pointSize: decoration.font_size_8 family: decoration.font_family } contentItem: Text { text: menuBarItem.text font: menuBarItem.font opacity: enabled ? 1.0 : 0.3 color: menuBarItem.highlighted ? "white":"#3F3F3F" horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } background: Rectangle { implicitWidth: 40 implicitHeight: 40 opacity: enabled ? 1 : 0.3 color: menuBarItem.highlighted ? "#292a38" : "transparent" } } background: Rectangle { implicitWidth: 40 implicitHeight: 11 color: "#d2d2d2" // This is the text I want before menus start Text{ text:"jjjjjjjjj"; anchors.left: parent.left} Rectangle { color: "#21be2b" width: parent.width height: 1 anchors.bottom: parent.bottom } } }
在 QML 的菜單欄中插入文本
慕后森
2024-01-18 20:31:18