Application QML Type

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

import 语句: import QtQuick

特性

信号

详细描述

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!")
        }
    }
}
					

另请参阅 SystemPalette .

特性文档编制

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 [read-only]

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

layoutDirection : Qt::LayoutDirection [read-only]

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 > [read-only]

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 ().

另请参阅 Screen , Window ,和 Window.screen .

state : Qt::ApplicationState [read-only]

This property represents the current state of the application.

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

styleHints : StyleHints [read-only]

The styleHints property provides platform-specific style hints and settings. See the QStyleHints 文档编制进一步了解细节。

The following example uses styleHints to determine whether an item should gain focus on mouse press or touch release:

import QtQuick
MouseArea {
    id: button
    onPressed: {
        if (!Application.styleHints.setFocusOnTouchRelease)
            button.forceActiveFocus()
    }
    onReleased: {
        if (Application.styleHints.setFocusOnTouchRelease)
            button.forceActiveFocus()
    }
}
					

supportsMultipleWindows : bool [read-only]

返回 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.

信号文档编制

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-second cleanup. User interaction is not possible in this state. For more information, see Window.closing .

注意: 相应处理程序是 onAboutToQuit .

另请参阅 QCoreApplication::aboutToQuit .