QML 菜单操作

QML 菜单操作

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5
import QtQuick.Controls 1.4 as Ctrl

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    menuBar:MenuBar{
        Menu {
            title: qsTr('&File')
            Action { text: "Cut" }
            Action { text: "Copy" }
            Action { text: "Paste" }

            MenuSeparator { }

            Menu {
                title: qsTr("Find/Replace")
                Action { text: "Find Next" }
                Action { text: "Find Previous" }
                Action { text: "Replace" }
            }

        }
        Menu {
            title: qsTr('&Help')
            Action {
                id: aboutAct
                text: "&About" }
        }

        Connections {
            target: aboutAct
            onTriggered: {
                print("about ... ")
            }
        }
    }

    header:ToolBar{
        Row{
           ToolButton{
               text: '打开'
                onClicked: {
                    print("打开。。。")
                }
           }
           ToolButton{
               text: '编辑'
           }
        }
    }

    footer : Ctrl.StatusBar{
        Row{
            Label{
                text: 'Menu '+ApplicationWindow.menuBar.count+' Count'
                font.italic: true
                color: 'red'
            }
        }
    }
}

你可能感兴趣的:(Qt开发,QML,QML学习)