代码之家  ›  专栏  ›  技术社区  ›  Martin Delille

qtl菜单栏在QtQuick应用程序中的显示

  •  0
  • Martin Delille  · 技术社区  · 7 年前

    我正在使用仅包含一个菜单栏的QML开发macOS应用程序:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.4
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        menuBar: MenuBar {
            Menu {
                title: qsTr("&File")
                Action { text: qsTr("&New...") }
                Action { text: qsTr("&Open...") }
                Action { text: qsTr("&Save") }
                Action { text: qsTr("Save &As...") }
                MenuSeparator { }
                Action { text: qsTr("&Quit") }
            }
            Menu {
                title: qsTr("&Edit")
                Action { text: qsTr("Cu&t") }
                Action { text: qsTr("&Copy") }
                Action { text: qsTr("&Paste") }
            }
            Menu {
                title: qsTr("&Help")
                Action { text: qsTr("&About") }
            }
        }
    }
    

    不幸的是,菜单看起来不像预期的那样:

    screenshot

    通常,菜单项出现在 苹果 菜单中只包含 菜单测试 在这里:

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  3
  •   dtech    7 年前

    您正在使用中的“库存”菜单 Controls -它不是“本地”菜单。

    您可以选择使用 Qt.labs.platform

    请记住,这将作为项目依赖项拖动QtWidgets模块。