Tuesday, October 1, 2013

QtQuick Controls: ApplicationWindow, MenuBar, ToolBar and StatusBar

ApplicationWindow, MenuBar, ToolBar and StatusBar
QtQuick Controls: ApplicationWindow, MenuBar, ToolBar and StatusBar

import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0
import QtQuick.Layouts 1.0

ApplicationWindow {
    id: myWindow
    title: "Qteveloper (http://qteveloper.blogspot.com/)"
    width: 480
    height: 320


    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            MenuItem {
                text: qsTr("Exit")
                onTriggered: Qt.quit();
            }
            MenuItem {
                text: "File - Item 2"
                onTriggered: statusLabel.text = "File - Item 2 Triggered"
            }
        }
        Menu {
            title: "Option B"
            MenuItem {
                text: "Opt B1"
                onTriggered: statusLabel.text = "Opt B1 Triggered"

            }
            MenuItem {
                text: "Opt B2"
                checkable: true
                onCheckedChanged: statusLabel.text = "Opt B2 Checked - "
                                  + checked
            }
            MenuItem {
                text: "Opt B3"
                checkable: true
                onCheckedChanged: statusLabel.text = "Opt B3 Checked - "
                                  + checked
            }
        }
    }

    toolBar: ToolBar{
        RowLayout{
            ToolButton{
                text: "ToolButton T1"
                onClicked: statusLabel.text = "ToolButton T1 clicked"
            }
            ToolButton{
                text: "ToolButton T2"
                onClicked: statusLabel.text = "ToolButton T2 clicked"
            }
            ToolButton{
                text: "ToolButton T3"
                onClicked: statusLabel.text = "ToolButton T3 clicked"
            }
        }
    }

    statusBar: StatusBar{
        RowLayout{
            Label{
                id: statusLabel
                text: "Status Bar"
            }
        }
    }
}



~ QtQuick Controls: Example to apply Action to MenuItem and ToolButton