Tuesday, October 15, 2013

QtQuick example: resizing Window

QtQuick example: resizing Window
QtQuick example: resizing 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: "Child Window"
        width: 300
        height: 300
        visible: false
        function open(){
            visible = true
        }
        function close(){
            visible = false
        }

        Rectangle {
            anchors.fill: parent

            Button {
                id: maxMe
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.top: parent.top
                text:"Maximize me"
                width: parent.width
                tooltip:"Maximize this child window"
                onClicked: myWindow.showMaximized()
            }
            Button {
                id: normalizeMe
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.top: maxMe.bottom
                text:"Normalize me"
                width: parent.width
                tooltip:"Normalize this child window"
                onClicked: myWindow.showNormal()
            }
            Button {
                id: minMe
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.top: normalizeMe.bottom
                text:"Minimized...but not work as expected!"
                width: parent.width
                tooltip:"Minimized this child window"
                onClicked: myWindow.showMinimized()
            }
            Button {
                id: closeMe
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.bottom: parent.bottom
                text:"Close me"
                width: parent.width
                tooltip:"Close this child Window"
                onClicked: myWindow.close()
            }
        }
    }
}