From 78d2cec488f8ab4ab45433ae9a9039f9cb7a5771 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 16 May 2023 06:54:55 +0200 Subject: doc: Make Window snippets testable; remove import versions Pick-to: 6.2 6.5 Change-Id: I35ba013152628591d016c632828a1c4e64cf5978 Reviewed-by: Oliver Eftevaag --- .../snippets/qml/nestedWindowTransientParent.qml | 23 ++++++++++++++++++++++ .../doc/snippets/qml/windowActiveAttached.qml | 10 ++++++++++ src/quick/items/qquickwindow.cpp | 22 +++------------------ 3 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 src/quick/doc/snippets/qml/nestedWindowTransientParent.qml create mode 100644 src/quick/doc/snippets/qml/windowActiveAttached.qml diff --git a/src/quick/doc/snippets/qml/nestedWindowTransientParent.qml b/src/quick/doc/snippets/qml/nestedWindowTransientParent.qml new file mode 100644 index 0000000000..51f076172d --- /dev/null +++ b/src/quick/doc/snippets/qml/nestedWindowTransientParent.qml @@ -0,0 +1,23 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick + +//![0] +Window { + // visible is false by default + Window { + transientParent: null + visible: true + } +//![0] + + id: outer + Timer { + interval: 2000 + running: true + onTriggered: outer.visible = true + } +//![1] +} +//![1] diff --git a/src/quick/doc/snippets/qml/windowActiveAttached.qml b/src/quick/doc/snippets/qml/windowActiveAttached.qml new file mode 100644 index 0000000000..791091ef82 --- /dev/null +++ b/src/quick/doc/snippets/qml/windowActiveAttached.qml @@ -0,0 +1,10 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +//![entire] +import QtQuick + +Text { + text: Window.active ? "active" : "inactive" +} +//![entire] diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 6a0c405be3..4684fb291e 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -3496,17 +3496,8 @@ void QQuickWindow::endExternalCommands() Item or Window within which it was declared, you can remove that relationship by setting \c transientParent to \c null: - \qml - import QtQuick.Window 2.13 - - Window { - // visible is false by default - Window { - transientParent: null - visible: true - } - } - \endqml + \snippet qml/nestedWindowTransientParent.qml 0 + \snippet qml/nestedWindowTransientParent.qml 1 In order to cause the window to be centered above its transient parent by default, depending on the window manager, it may also be necessary to set @@ -3568,14 +3559,7 @@ void QQuickWindow::endExternalCommands() Here is an example which changes a label to show the active state of the window in which it is shown: - \qml - import QtQuick 2.4 - import QtQuick.Window 2.2 - - Text { - text: Window.active ? "active" : "inactive" - } - \endqml + \snippet qml/windowActiveAttached.qml entire */ /*! -- cgit v1.2.1