ApplicationWindow QML 类型

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

导入语句: import QtQuick.Controls 2.2
Since: Qt 5.7
继承:

Window

特性

附加特性

详细描述

ApplicationWindow Window which makes it convenient to add a 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.1
ApplicationWindow {
    visible: true
    header: ToolBar {
        // ...
    }
    footer: TabBar {
        // ...
    }
    StackView {
        anchors.fill: parent
    }
}
					

ApplicationWindow supports popups via its overlay property, which ensures that popups are displayed above other content and that the background is dimmed when a modal or dimmed popup is visible.

注意: By default, an ApplicationWindow is not visible.

Attached ApplicationWindow Properties

Due to how 作用域和命名分辨率 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 . The following example uses the attached overlay property to position the popup to the center of the window, despite the position of the button that opens the popup.

Button {
    onClicked: popup.open()
    Popup {
        id: popup
        parent: ApplicationWindow.overlay
        x: (parent.width - width) / 2
        y: (parent.height - height) / 2
        width: 100
        height: 100
    }
}
					

另请参阅 Customizing ApplicationWindow , Page ,和 容器控件 .

特性文档编制

[read-only] activeFocusControl : Control

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

差异在 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 SpinBox 本身。

另请参阅 Window::activeFocusItem .


background : Item

此特性保持背景项。

The background item is stacked under the content item , but above the background color 为窗口。

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.

注意: 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.

另请参阅 Customizing ApplicationWindow , contentItem , header , footer ,和 overlay .


[default] contentData : list < Object >

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.

另请参阅 contentItem .


[read-only] contentItem : Item

This property holds the window content item.

The content item is stacked above the background item, and under the header , footer ,和 overlay 项。

另请参阅 background , header , footer ,和 overlay .


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.

另请参阅 Control::font .


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 {
        // ...
    }
}
					

注意: Assigning a ToolBar , TabBar ,或 DialogButtonBox as a window footer automatically sets the respective ToolBar::position , TabBar::position ,或 DialogButtonBox::position 特性到 Footer .

另请参阅 header and Page::footer .


header : Item

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

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

注意: Assigning a ToolBar , TabBar ,或 DialogButtonBox as a window header automatically sets the respective ToolBar::position , TabBar::position ,或 DialogButtonBox::position 特性到 Header .

另请参阅 footer and Page::header .


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.

另请参阅 Control::locale and LayoutMirroring .


overlay group

overlay : Item

overlay.modal : 组件

overlay.modeless : 组件

This property holds the window overlay item. Popups are automatically reparented to the overlay.

特性 描述
overlay.modal This property holds a component to use as a visual item that implements background dimming for modal popups. It is created for and stacked below visible modal popups.
overlay.modeless This property holds a component to use as a visual item that implements background dimming for modeless popups. It is created for and stacked below visible dimming popups.
overlay.pressed() This signal is emitted when the overlay is pressed by the user while a popup is visible.
overlay.released() This signal is emitted when the overlay is released by the user while a modal popup is visible.

另请参阅 Popup::modal and Popup::dim .


附加特性文档编制

[read-only] ApplicationWindow.activeFocusControl : Control

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 an ApplicationWindow , or the window has no active focus.

另请参阅 Window::activeFocusItem and Attached ApplicationWindow Properties .


[read-only] ApplicationWindow.contentItem : Item

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 .

另请参阅 Attached ApplicationWindow Properties .


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.

另请参阅 Attached ApplicationWindow Properties .


[read-only] ApplicationWindow.header : Item

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.

另请参阅 Attached ApplicationWindow Properties .


[read-only] ApplicationWindow.overlay : Item

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

另请参阅 Attached ApplicationWindow Properties .


[read-only] ApplicationWindow.window : ApplicationWindow

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 .

另请参阅 Attached ApplicationWindow Properties .