Window QML Type▲
-
Import Statement: import QtQuick
-
Instantiates:: QQuickWindow
-
Group: Window is part of qtquick-visual
Detailed Description▲
The Window object creates a new top-level window for a Qt Quick scene. It automatically sets up the window for use with QtQuick graphical types.
A Window can be declared inside an Item or inside another Window; in that case the inner Window will automatically become "transient for" the outer Window: that is, most platforms will show it centered upon the outer window by default, and there may be other platform-dependent behaviors, depending also on the flags. If the nested window is intended to be a dialog in your application, you should also set flags to Qt.Dialog, because some window managers will not provide the centering behavior without that flag. You can also declare multiple windows inside a top-level QtObject, in which case the windows will have no transient relationship.
Alternatively you can set or bind x and y to position the Window explicitly on the screen.
When the user attempts to close a window, the closing signal will be emitted. You can force the window to stay open (for example to prompt the user to save changes) by writing an onClosing handler that sets close.accepted = false unless it's safe to close the window (for example, because there are no more unsaved changes).
onClosing
:
(close) =&
gt; {
if
(document.changed) {
close.accepted =
false
confirmExitPopup.open()
}
}
// The confirmExitPopup allows user to save or discard the document,
// or to cancel the closing.
Property Documentation▲
height : int▲
width : int
x : int
y : int
Defines the window's position and size.
The (x,y) position is relative to the Screen if there is only one, or to the virtual desktop (arrangement of multiple screens).
Window
{
x
:
100
; y
:
100
; width
:
100
; height
:
100
}
[since 5.1] minimumHeight : int▲
[since 5.1] minimumWidth : int
Defines the window's minimum size.
This is a hint to the window manager to prevent resizing below the specified width and height.
This QML property was introduced in Qt 5.1.
[since 5.1] maximumHeight : int▲
[since 5.1] maximumWidth : int
Defines the window's maximum size.
This is a hint to the window manager to prevent resizing above the specified width and height.
This QML property was introduced in Qt 5.1.
[read-only, since 5.1] active : bool▲
The active status of the window.
This property was introduced in Qt 5.1.
See Also▲
See also requestActivate()
[read-only, since 5.1] activeFocusItem : Item▲
The item which currently has active focus or null if there is no item with active focus.
This property was introduced in Qt 5.1.
color : color▲
The background color for the window.
Setting this property is more efficient than using a separate Rectangle.
[read-only] contentItem : Item▲
The invisible root item of the scene.
[since 5.1] contentOrientation : Qt::ScreenOrientation▲
This is a hint to the window manager in case it needs to display additional content like popups, dialogs, status bars, or similar in relation to the window.
The recommended orientation is Screen.orientation, but an application doesn't have to support all possible orientations, and thus can opt to ignore the current screen orientation.
The difference between the window and the content orientation determines how much to rotate the content by.
The default value is Qt::PrimaryOrientation.
This property was introduced in Qt 5.1.
See Also▲
See also Screen
[default] data : list<QtObject>▲
The data property allows you to freely mix visual children, resources and other Windows in a Window.
If you assign another Window to the data list, the nested window will become "transient for" the outer Window.
If you assign an Item to the data 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, which is the root of the Item ownership tree within that Window.
If you assign any other object type, it is added as a resource.
It should not generally be necessary to refer to the data property, as it is the default property for Window and thus all child items are automatically assigned to this property.
See Also▲
See also QWindow::transientParent()
flags : Qt::WindowFlags▲
The window flags of the window.
The window flags control the window's appearance in the windowing system, whether it's a dialog, popup, or a regular window, and whether it should have a title bar, etc.
The flags which you read from this property might differ from the ones that you set if the requested flags could not be fulfilled.
See Also▲
See also Qt::WindowFlags
modality : Qt::WindowModality▲
The modality of the window.
A modal window prevents other windows from receiving input events. Possible values are Qt.NonModal (the default), Qt.WindowModal, and Qt.ApplicationModal.
[since 5.1] opacity : real▲
The opacity of the window.
If the windowing system supports window opacity, this can be used to fade the window in and out, or to make it semitransparent.
A value of 1.0 or above is treated as fully opaque, whereas a value of 0.0 or below is treated as fully transparent. Values inbetween represent varying levels of translucency between the two extremes.
The default value is 1.0.
This property was introduced in Qt 5.1.
[since 6.0] palette : Palette▲
This property holds the palette currently set for the window.
The default palette depends on the system environment. QGuiApplication maintains a system/theme palette which serves as a default for all application windows. You can also s