第2章:MenuBarQML基本コンポーネントのMenuBar

メニューバー

ApplicationWindow

 

効果画像:

 

ソースコード:

import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
ApplicationWindow {
    visible: true
    width: 640
    height: 480
    color: "black";
    title: "菜单显示";
    id: root;
    menuBar: MenuBar{
        Menu {
            title: "文件";
            MenuItem{
                text: "退出";
                onTriggered: Qt.quit();
            }
        }
        Menu {
            title: "帮助";
            MenuItem{
                text: "关于";
                onTriggered: root.showAbout();
            }
            MenuItem{
                text: "官网";
                onTriggered: Qt.openUrlExternally("http://www.baidu.com");
            }
        }
    }
}

 

おすすめ

転載: blog.csdn.net/qq_40602000/article/details/109276858