Tuesday, October 8, 2013

QtQuick example: open and close new Window

QtQuick example: open and close new Window
QtQuick example: open and close new Window


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

ApplicationWindow {
    title: "Qteveloper (http://qteveloper.blogspot.com/)"
    width: 400
    height: 380

    menuBar: MenuBar {
        Menu {
            title: "Sub-Window"
            MenuItem {
                text: "Open"
                onTriggered: myWindow.open();
            }
            MenuItem {
                text: "Close"
                onTriggered: myWindow.close();
            }
        }
    }

    Window{
        id: myWindow
        title: "myWindow"
        width: 300
        height: 300
        visible: false
        function open(){
            visible = true
        }
        function close(){
            visible = false
        }
    }
}