Qt QML 菜单栏和菜单未显示

Qt QML MenuBar and Menus not showing

本文关键字:显示 菜单 QML 菜单栏 Qt      更新时间:2023-10-16

我是Qt和Qt/QML的新手,我正在尝试设置菜单栏,但它根本没有显示它。

我已经复制了粘贴的代码,但仍然一无所获(来自 Qt 文档)。

import QtQuick 2.0
import QtQuick.Controls 1.0
ApplicationWindow {
    visible: true;
    width: 1000;
    height: 700;
    title: "App";
    MenuBar {
        Menu {
            title: "File"
            MenuItem { text: "Open..." }
            MenuItem { text: "Close" }
        }
        Menu {
            title: "Edit"
            MenuItem { text: "Cut" }
            MenuItem { text: "Copy" }
            MenuItem { text: "Paste" }
        }
    }
}

使用

menuBar: MenuBar{//Menubar content}

而不是

MenuBar{//Menubar content}