aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickapplicationwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates2/qquickapplicationwindow.cpp')
-rw-r--r--src/quicktemplates2/qquickapplicationwindow.cpp67
1 files changed, 64 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp
index 7f65b8bf..87dc8816 100644
--- a/src/quicktemplates2/qquickapplicationwindow.cpp
+++ b/src/quicktemplates2/qquickapplicationwindow.cpp
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-containers
- \brief Provides a top-level application window.
+ \brief Styled top-level window with support for a header and footer.
ApplicationWindow is a \l Window which makes it convenient to add
a \l header and \l footer item to the window.
@@ -90,10 +90,45 @@ QT_BEGIN_NAMESPACE
ApplicationWindow supports popups via its \l overlay property, which
ensures that popups are displayed above other content and that the
- background is dimmed when a modal popup is visible.
+ background is dimmed when a \l {Popup::}{modal} or \l {Popup::dim}
+ {dimmed} popup is visible.
\note By default, an ApplicationWindow is not visible.
+ \section2 Attached ApplicationWindow Properties
+
+ Due to how \l {Scope and Naming Resolution} works in QML, it is possible
+ to reference the \c id of the application root element anywhere in its
+ child QML objects. Even though this approach is fine for many applications
+ and use cases, for a generic QML component it may not be acceptable as it
+ creates a dependency to the surrounding environment.
+
+ ApplicationWindow provides a set of attached properties that can be used
+ to access the window and its building blocks from places where no direct
+ access to the window is available, without creating a dependency to a
+ certain window \c id. A QML component that uses the ApplicationWindow
+ attached properties works in any window regardless of its \c id. The
+ following example uses the attached \c overlay property to position the
+ popup to the center of the window, despite the position of the button
+ that opens the popup.
+
+ \code
+ Button {
+ onClicked: popup.open()
+
+ Popup {
+ id: popup
+
+ parent: ApplicationWindow.overlay
+
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 100
+ height: 100
+ }
+ }
+ \endcode
+
\sa {Customizing ApplicationWindow}, Page, {Container Controls}
*/
@@ -315,6 +350,14 @@ void QQuickApplicationWindow::setBackground(QQuickItem *background)
This property holds the window header item. The header item is positioned to
the top, and resized to the width of the window. The default value is \c null.
+ \code
+ ApplicationWindow {
+ header: TabBar {
+ // ...
+ }
+ }
+ \endcode
+
\note Assigning a ToolBar, TabBar, or DialogButtonBox as a window header
automatically sets the respective \l ToolBar::position, \l TabBar::position,
or \l DialogButtonBox::position property to \c Header.
@@ -364,6 +407,14 @@ void QQuickApplicationWindow::setHeader(QQuickItem *header)
This property holds the window footer item. The footer item is positioned to
the bottom, and resized to the width of the window. The default value is \c null.
+ \code
+ ApplicationWindow {
+ footer: ToolBar {
+ // ...
+ }
+ }
+ \endcode
+
\note Assigning a ToolBar, TabBar, or DialogButtonBox as a window footer
automatically sets the respective \l ToolBar::position, \l TabBar::position,
or \l DialogButtonBox::position property to \c Footer.
@@ -726,6 +777,8 @@ QQuickApplicationWindowAttached::QQuickApplicationWindowAttached(QObject *parent
This attached property holds the application window. The property can be attached
to any item. The value is \c null if the item is not in an ApplicationWindow.
+
+ \sa {Attached ApplicationWindow Properties}
*/
QQuickApplicationWindow *QQuickApplicationWindowAttached::window() const
{
@@ -739,6 +792,8 @@ QQuickApplicationWindow *QQuickApplicationWindowAttached::window() const
This attached property holds the window content item. The property can be attached
to any item. The value is \c null if the item is not in an ApplicationWindow.
+
+ \sa {Attached ApplicationWindow Properties}
*/
QQuickItem *QQuickApplicationWindowAttached::contentItem() const
{
@@ -757,7 +812,7 @@ QQuickItem *QQuickApplicationWindowAttached::contentItem() const
The value is \c null if the item is not in an ApplicationWindow, or the window has
no active focus.
- \sa Window::activeFocusItem
+ \sa Window::activeFocusItem, {Attached ApplicationWindow Properties}
*/
QQuickItem *QQuickApplicationWindowAttached::activeFocusControl() const
{
@@ -774,6 +829,8 @@ QQuickItem *QQuickApplicationWindowAttached::activeFocusControl() const
This attached property holds the window header item. The property can be attached
to any item. The value is \c null if the item is not in an ApplicationWindow, or
the window has no header item.
+
+ \sa {Attached ApplicationWindow Properties}
*/
QQuickItem *QQuickApplicationWindowAttached::header() const
{
@@ -790,6 +847,8 @@ QQuickItem *QQuickApplicationWindowAttached::header() const
This attached property holds the window footer item. The property can be attached
to any item. The value is \c null if the item is not in an ApplicationWindow, or
the window has no footer item.
+
+ \sa {Attached ApplicationWindow Properties}
*/
QQuickItem *QQuickApplicationWindowAttached::footer() const
{
@@ -805,6 +864,8 @@ QQuickItem *QQuickApplicationWindowAttached::footer() const
This attached property holds the window overlay item. The property can be attached
to any item. The value is \c null if the item is not in an ApplicationWindow.
+
+ \sa {Attached ApplicationWindow Properties}
*/
QQuickOverlay *QQuickApplicationWindowAttached::overlay() const
{