diff options
Diffstat (limited to 'examples/quick/window')
-rw-r--r-- | examples/quick/window/CMakeLists.txt | 34 | ||||
-rw-r--r-- | examples/quick/window/Splash.qml | 19 | ||||
-rw-r--r-- | examples/quick/window/doc/src/window.qdoc | 1 | ||||
-rw-r--r-- | examples/quick/window/window.qml | 46 | ||||
-rw-r--r-- | examples/quick/window/window.qrc | 2 |
5 files changed, 56 insertions, 46 deletions
diff --git a/examples/quick/window/CMakeLists.txt b/examples/quick/window/CMakeLists.txt index 31932654ea..58bd8fd7e9 100644 --- a/examples/quick/window/CMakeLists.txt +++ b/examples/quick/window/CMakeLists.txt @@ -1,18 +1,12 @@ # Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause cmake_minimum_required(VERSION 3.16) project(window LANGUAGES CXX) -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/window") - find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) -qt_standard_project_setup() +qt_standard_project_setup(REQUIRES 6.5) add_subdirectory("../shared" "shared") @@ -23,15 +17,14 @@ qt_add_executable(windowexample ) target_link_libraries(windowexample PRIVATE - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick + Qt6::Core + Qt6::Gui + Qt6::Qml + Qt6::Quick ) qt_add_qml_module(windowexample URI window - AUTO_RESOURCE_PREFIX QML_FILES "AllScreens.qml" "CurrentScreen.qml" @@ -42,9 +35,16 @@ qt_add_qml_module(windowexample add_dependencies(windowexample window_shared) install(TARGETS windowexample - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -bundle_shared(windowexample) +qt_generate_deploy_qml_app_script( + TARGET windowexample + OUTPUT_SCRIPT deploy_script + MACOS_BUNDLE_POST_BUILD + NO_UNSUPPORTED_PLATFORM_ERROR + DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM +) +install(SCRIPT ${deploy_script}) diff --git a/examples/quick/window/Splash.qml b/examples/quick/window/Splash.qml index 0a7da219db..6989425548 100644 --- a/examples/quick/window/Splash.qml +++ b/examples/quick/window/Splash.qml @@ -24,19 +24,20 @@ Window { Image { id: splashImage source: Images.qtLogo - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() + TapHandler { + onTapped: splash.exit() } } + + function exit() { + splash.visible = false + splash.timeout() + } + //! [timer] Timer { - interval: splash.timeoutInterval; running: true; repeat: false - onTriggered: { - splash.visible = false - splash.timeout() - } + interval: splash.timeoutInterval; running: splash.visible; repeat: false + onTriggered: splash.exit() } //! [timer] - Component.onCompleted: visible = true } diff --git a/examples/quick/window/doc/src/window.qdoc b/examples/quick/window/doc/src/window.qdoc index 3dfbf1cd0c..ca3b90b76e 100644 --- a/examples/quick/window/doc/src/window.qdoc +++ b/examples/quick/window/doc/src/window.qdoc @@ -6,6 +6,7 @@ \brief This example demonstrates the Window and Screen types in QML. \image qml-window-example.png \ingroup qtquickexamples + \examplecategory {Graphics} \e{Window and Screen} shows how to: diff --git a/examples/quick/window/window.qml b/examples/quick/window/window.qml index 47cc5257bb..99ff4403e4 100644 --- a/examples/quick/window/window.qml +++ b/examples/quick/window/window.qml @@ -7,12 +7,11 @@ import QtQuick.Controls QtObject { id: root property real defaultSpacing: 10 - property SystemPalette palette: SystemPalette { } property var controlWindow: Window { width: col.implicitWidth + root.defaultSpacing * 2 height: col.implicitHeight + root.defaultSpacing * 2 - color: root.palette.window + color: palette.window title: "Control Window" Column { id: col @@ -90,13 +89,13 @@ QtObject { " and has visibility " + parent.visibilityToString(root.testWindow.visibility) } Rectangle { - color: root.palette.text + color: palette.text width: parent.width height: 1 } CurrentScreen { } Rectangle { - color: root.palette.text + color: palette.text width: parent.width height: 1 } @@ -117,35 +116,44 @@ QtObject { anchors.centerIn: parent text: "Second Window" } - MouseArea { - anchors.fill: parent - onClicked: root.testWindow.color = "#e0c31e" + TapHandler { + onTapped: root.testWindow.color = Qt.rgba(0.25 + Math.random() / 2, + 0.65 + Math.random() / 4, + 0.15 + Math.random() / 3) } Button { - anchors.right: parent.right - anchors.top: parent.top - anchors.margins: root.defaultSpacing - text: root.testWindow.visibility === Window.FullScreen ? "exit fullscreen" : "go fullscreen" - width: 150 - onClicked: { - if (root.testWindow.visibility === Window.FullScreen) - root.testWindow.visibility = Window.AutomaticVisibility - else - root.testWindow.visibility = Window.FullScreen + id: fullscreenButton + anchors { + right: parent.right + top: parent.top + margins: root.defaultSpacing } + width: height + checkable: true + Binding on checked { value: root.testWindow.visibility === Window.FullScreen } + onClicked: root.testWindow.visibility = checked ? Window.FullScreen : Window.AutomaticVisibility + text: "⛶" + ToolTip.visible: hovered + ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval + ToolTip.text: root.testWindow.visibility === Window.FullScreen ? qsTr("restore") : qsTr("fill screen") } Button { anchors.left: parent.left anchors.top: parent.top anchors.margins: root.defaultSpacing - text: "X" - width: 30 + text: "✘" + width: height + height: fullscreenButton.height onClicked: root.testWindow.close() + ToolTip.visible: hovered + ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval + ToolTip.text: qsTr("close this window") } } } property var splashWindow: Splash { + visible: true onTimeout: root.controlWindow.visible = true } } diff --git a/examples/quick/window/window.qrc b/examples/quick/window/window.qrc index 89d1de1b1f..206491cc13 100644 --- a/examples/quick/window/window.qrc +++ b/examples/quick/window/window.qrc @@ -1,5 +1,5 @@ <RCC> - <qresource prefix="/window"> + <qresource prefix="/qt/qml/window"> <file>window.qml</file> <file>Splash.qml</file> <file>CurrentScreen.qml</file> |