W3cubDocs

/Qt

Application QML Type

Provides access to global application state properties shared by many QML components. More...

Import Statement: import QtQuick

Properties

Signals

Detailed Description

The Application singleton exposes a subset of QApplication's properties to QML applications.

It also provides an aboutToQuit() signal, which is the same as QCoreApplication::aboutToQuit().

import QtQuick

Window {
    id: root
    visible: true
    width: 800
    height: 680

    title: `${Application.name} (${Application.version})`

    Connections {
        target: Application
        function onAboutToQuit() {
            console.log("Bye!")
        }
    }
}

Property Documentation

arguments : QStringList

This is a string list of the arguments the executable was invoked with.

displayName : QString

This property represents the application display name set on the QGuiApplication instance. This property can be written to in order to set the application display name.

Binding {
    target: Application
    property: "displayName"
    value: "My Awesome Application"
}

domain : QString

This is the organization domain set on the QCoreApplication instance. This property can be written to in order to set the organization domain.

font : QFont

Returns the default application font as returned by QGuiApplication::font().

layoutDirection : Qt::LayoutDiretcion

This read-only property can be used to query the default layout direction of the application. On system start-up, the default layout direction depends on the application's language. The property has a value of Qt.RightToLeft in locales where text and graphic elements are read from right to left, and Qt.LeftToRight where the reading direction flows from left to right. You can bind to this property to customize your application layouts to support both layout directions.

RowLayout {
    layoutDirection: Application.layoutDirection
}

name : QString

This is the application name set on the QCoreApplication instance. This property can be written to in order to set the application name.

organization : QString

This is the organization name set on the QCoreApplication instance. This property can be written to in order to set the organization name.

screens : QQmlListProperty<QQuickScreenInfo>

An array containing the descriptions of all connected screens. The elements of the array are objects with the same properties as the Screen attached object. In practice the array corresponds to the screen list returned by QGuiApplication::screens(). In addition to examining properties like name, width, height, etc., the array elements can also be assigned to the screen property of Window items, thus serving as an alternative to the C++ side's QWindow::setScreen().

See also Screen, Window, and Window.screen.

state : Qt::ApplicationState

This property represents the current state of the application.

Timer {
    interval: 1000; repeat: true
    active: Application.state === Qt.Qt.ApplicationActive
    onTriggered: imageFetcher.fetchLatestImages()
}

supportsMultipleWindows : bool

Returns true if the platform supports multiple windows. Some embedded platforms do not support multiple windows, for example.

version : QString

This is the application version set on the QCoreApplication instance. This property can be written to in order to set the application version.

Signal Documentation

aboutToQuit()

This signal is emitted when the application is about to quit the main event loop. The signal is particularly useful if your application has to do some last-secondcleanup. Note that no user interaction is possible in this state.

Note: The corresponding handler is onAboutToQuit.

See also QCoreApplication::aboutToQuit.

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.2/qml-qtquick-application.html