- Qt 6.9
- Qt Quick Controls
- QML Types
- ApplicationWindow
- Qt 6.9.1 Reference Documentation

# ApplicationWindow QML Type

Styled top-level window with support for a header and footer. More...

Import Statement: | `import QtQuick.Controls`
Inherits: | Window

- List of all members, including inherited members

## Properties

- activeFocusControl : Control
- background : Item
- bottomPadding : real `(since 6.9)`
- contentData : list<QtObject>
- contentItem : Item
- font : font
- footer : Item
- header : Item
- leftPadding : real `(since 6.9)`
- locale : Locale
- menuBar : Item `(since QtQuick.Controls 2.3 (Qt 5.10))`
- rightPadding : real `(since 6.9)`
- topPadding : real `(since 6.9)`

## Attached Properties

- activeFocusControl : Control
- contentItem : Item
- footer : Item
- header : Item
- menuBar : Item `(since QtQuick.Controls 2.3 (Qt 5.10))`
- window : ApplicationWindow

## Detailed Description

ApplicationWindow is a Window which makes it convenient to add a menu bar, header and footer item to the window.

You can declare ApplicationWindow as the root item of your application, and run it by using QQmlApplicationEngine. In this way you can control the window's properties, appearance and layout from QML.

     import QtQuick.Controls 2.12

     ApplicationWindow {
         visible: true

         menuBar: MenuBar {
             // ...
         }

         header: ToolBar {
             // ...
         }

         footer: TabBar {
             // ...
         }

         StackView {
             anchors.fill: parent
         }
     }

Note: By default, an ApplicationWindow is not visible.

### Attached ApplicationWindow Properties

Due to how Scope and Naming Resolution works in QML, it is possible to reference the `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 `id`. A QML component that uses the ApplicationWindow attached properties works in any window regardless of its `id`.

### Safe Areas

Since Qt 6.9 ApplicationWindow will automatically add padding to the contentItem for any safe area margins reported by the window. This ensures that the contentItem stays inside the safe area of the window, while the background item covers the entire window.

If you are manually handing safe area margins in the window's contentItem you can override the default via the topPadding, leftPadding, rightPadding and bottomPadding properties:

     ApplicationWindow {
         // Remove automatic safe area padding
         topPadding: 0

         Flickable {
             // Inset content by safe area margin
             topMargin: SafeArea.margins.top
         }
     }

The header, footer, and menuBar properties do not receive any automatic padding for the safe area margins. However, depending on the style in use, the style may take safe areas into account in its implementation of ToolBar, TabBar, and MenuBar.

See also Customizing ApplicationWindow, Overlay, Page, Container Controls, and Focus Management in Qt Quick Controls.

## Property Documentation

activeFocusControl : Control `[read-only]`

This property holds the control that currently has active focus, or `null` if there is no control with active focus.

The difference between Window::activeFocusItem and ApplicationWindow::activeFocusControl is that the former may point to a building block of a control, whereas the latter points to the enclosing control. For example, when SpinBox has focus, activeFocusItem points to the editor and activeFocusControl to the SpinBox itself.

See also Window::activeFocusItem.

background : Item

This property holds the background item.

The background item is stacked under the content item, but above the background color of the window.

The background item is useful for images and gradients, for example, but the color property is preferable for solid colors, as it doesn't need to create an item.

Note: If the background item has no explicit size specified, it automatically follows the control's size. In most cases, there is no need to specify width or height for a background item.

See also Customizing ApplicationWindow, contentItem, header, and footer.

bottomPadding : real `[since 6.9]`

This property holds the bottom padding of the window's content item. Unless explicitly set, the value reflects the window's safe area margins.

This property was introduced in Qt 6.9.

See also topPadding, leftPadding, and rightPadding.

contentData : list<QtObject> `[default]`

This default property holds the list of all objects declared as children of the window.

The data property allows you to freely mix visual children, resources and other windows in an ApplicationWindow.

If you assign an Item to the contentData list, it becomes a child of the window's contentItem, so that it appears inside the window. The item's parent will be the window's contentItem.

It should not generally be necessary to refer to the contentData property, as it is the default property for ApplicationWindow and thus all child items are automatically assigned to this property.

See also contentItem.

contentItem : Item `[read-only]`

This property holds the window content item.

The content item is stacked above the background item, and under the menuBar, header, and footer items.

Since Qt 6.9 ApplicationWindow will automatically add padding to the contentItem for any safe area margins reported by the window. To override the padding use the individual padding properties.

See also background, menuBar, header, footer, topPadding, bottomPadding, leftPadding, and rightPadding.

font : font

This property holds the font currently set for the window.

The default font depends on the system environment. QGuiApplication maintains a system/theme font which serves as a default for all application windows. You can also set the default font for windows by passing a custom font to QGuiApplication::setFont(), before loading any QML. Finally, the font is matched against Qt's font database to find the best match.

ApplicationWindow propagates explicit font properties to child controls. If you change a specific property on the window's font, that property propagates to all child controls in the window, overriding any system defaults for that property.

See also Control::font.

footer : Item

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 `null`.

     ApplicationWindow {
         footer: ToolBar {
             // ...
         }
     }

Note: Assigning a ToolBar, TabBar, or DialogButtonBox as a window footer automatically sets the respective ToolBar::position, TabBar::position, or DialogButtonBox::position property to `Footer`.

See also menuBar, header, and Page::footer.

header : Item

This property holds the window header item. The header item is positioned at the top of the window, below the menu bar, and resized to the width of the window. The default value is `null`.

     ApplicationWindow {
         header: TabBar {
             // ...
         }
     }

Note: Assigning a ToolBar, TabBar, or DialogButtonBox as a window header automatically sets the respective ToolBar::position, TabBar::position, or DialogButtonBox::position property to `Header`.

See also menuBar, footer, and Page::header.

leftPadding : real `[since 6.9]`

This property holds the left padding of the window's content item. Unless explicitly set, the value reflects the window's safe area margins.

This property was introduced in Qt 6.9.

See also bottomPadding, topPadding, and rightPadding.

locale : Locale

This property holds the locale of the window.

The default locale depends on the system environment. You can set the default locale by calling QLocale::setDefault(), before loading any QML.

ApplicationWindow propagates the locale to child controls. If you change the window's locale, that locale propagates to all child controls in the window, overriding the system default locale.

See also Control::locale.

menuBar : Item `[since QtQuick.Controls 2.3 (Qt 5.10)]`

This property holds the window menu bar. The menu bar is positioned at the top of the window, above the header, and resized to the width of the window. The default value is `null`.

     ApplicationWindow {
         menuBar: MenuBar {
             // ...
         }
     }

This property was introduced in QtQuick.Controls 2.3 (Qt 5.10).

See also header, footer, and MenuBar.

rightPadding : real `[since 6.9]`

This property holds the right padding of the window's content item. Unless explicitly set, the value reflects the window's safe area margins.

This property was introduced in Qt 6.9.

See also bottomPadding, leftPadding, and topPadding.

topPadding : real `[since 6.9]`

This property holds the top padding of the window's content item. Unless explicitly set, the value reflects the window's safe area margins.

This property was introduced in Qt 6.9.

See also bottomPadding, leftPadding, and rightPadding.

## Attached Property Documentation

ApplicationWindow.activeFocusControl : Control `[read-only]`

This attached property holds the control that currently has active focus, or `null` if there is no control with active focus. The property can be attached to any item. The value is `null` if the item is not in a window, or the window has no active focus.

See also Window::activeFocusItem and Attached ApplicationWindow Properties.

ApplicationWindow.contentItem : Item `[read-only]`

This attached property holds the window content item. The property can be attached to any item. The value is `null` if the item is not in an ApplicationWindow.

See also Attached ApplicationWindow Properties.

ApplicationWindow.footer : Item `[read-only]`

This attached property holds the window footer item. The property can be attached to any item. The value is `null` if the item is not in an ApplicationWindow, or the window has no footer item.

See also Attached ApplicationWindow Properties.

ApplicationWindow.header : Item `[read-only]`

This attached property holds the window header item. The property can be attached to any item. The value is `null` if the item is not in an ApplicationWindow, or the window has no header item.

See also Attached ApplicationWindow Properties.

ApplicationWindow.menuBar : Item `[read-only, since QtQuick.Controls 2.3 (Qt 5.10)]`

This attached property holds the window menu bar. The property can be attached to any item. The value is `null` if the item is not in an ApplicationWindow, or the window has no menu bar.

This property was introduced in QtQuick.Controls 2.3 (Qt 5.10).

See also Attached ApplicationWindow Properties.

ApplicationWindow.window : ApplicationWindow `[read-only]`

This attached property holds the application window. The property can be attached to any item. The value is `null` if the item is not in an ApplicationWindow.

See also Attached ApplicationWindow Properties.