diff options
Diffstat (limited to 'examples/window/window/standalone.qml')
-rw-r--r-- | examples/window/window/standalone.qml | 91 |
1 files changed, 74 insertions, 17 deletions
diff --git a/examples/window/window/standalone.qml b/examples/window/window/standalone.qml index 5d96c37142..a7a7ed2d7a 100644 --- a/examples/window/window/standalone.qml +++ b/examples/window/window/standalone.qml @@ -39,33 +39,90 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick.Window 2.0 as Window +import QtQuick.Window 2.0 Item { - width: 640 - height: 480 + width: 320 + height: 240 + // It's not possible to set an Item's windowTitle. If you want to modify + // window properties, you need to explicitly create a Window. Text { + id: text1 anchors.centerIn: parent - text: "First Window" + text: "First Window\n" + (Qt.application.supportsMultipleWindows ? + "click the button to open a second window" : "only one window is allowed") } - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() + Rectangle { + border.color: "black" + radius: 4 + anchors.top: text1.bottom + anchors.horizontalCenter: text1.horizontalCenter + width: 100 + height: 30 + TextInput { + id: ti1 + focus: true // but the modal popup will prevent input while it is open + anchors.centerIn: parent + } } - Window.Window { - width: 640 - height: 480 - x: 640 - y: 480 - visible: true - color: "green" + Rectangle { + border.color: "black" + color: childWindow.visible ? "goldenrod" : "beige" + radius: height / 4 + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.margins: 10 + width: text.implicitWidth + 20 + height: text.implicitHeight + 20 + visible: Qt.application.supportsMultipleWindows Text { + id: text + text: "Pop up window" anchors.centerIn: parent - text: "Second Window" } - MouseArea{ + MouseArea { anchors.fill: parent - onClicked: Qt.quit() + onClicked: childWindow.visible = !childWindow.visible + } + } + + Window { + id: childWindow + width: 320 + height: 240 + x: 220 + y: 120 + color: "beige" + title: "Second Window" + modality: Qt.ApplicationModal + flags: Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint + Text { + id: text2 + anchors.centerIn: parent + text: "Modal Frameless Stay-on-Top Window" + } + Text { + anchors.top: parent.top + anchors.right: parent.right + anchors.margins: 10 + text: "X" + MouseArea{ + anchors.fill: parent + onClicked: childWindow.visible = false + } + } + Rectangle { + border.color: "black" + radius: 4 + anchors.top: text2.bottom + anchors.horizontalCenter: text2.horizontalCenter + width: 100 + height: 30 + TextInput { + id: ti2 + focus: true + anchors.centerIn: parent + } } } } |