亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 QML 的菜單欄中插入文本

在 QML 的菜單欄中插入文本

慕后森 2024-01-18 20:31:18
這些菜單默認顯示在左側。我想在菜單開始出現之前在左側放置一些文本。如何將菜單向右推以便為菜單欄中的文本創建空間?我想要以下內容:該文本“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            }        }    }
查看完整描述

1 回答

?
慕森卡

TA貢獻1806條經驗 獲得超8個贊

可能有更漂亮的解決方案,但它可以通過在禁用的列表前面添加一個特殊的菜單項來工作。


MenuBar {

    id: menuBar


    Menu { title: "jjjjjjjj" }

    Menu { title: qsTr("File") }

    Menu { title: qsTr("Edit") }

    Menu { title: qsTr("View") }

    Menu { title: qsTr("Help") }


    delegate: MenuBarItem {

        id: menuBarItem


        enabled: text !== "jjjjjjjj"

    }

}


查看完整回答
反對 回復 2024-01-18
  • 1 回答
  • 0 關注
  • 210 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號