QML:Qt QML Type
The QML global Qt object provides useful enums and functions from Qt. More...
Import Statement: | import . |
Properties
- application : object
Detailed Description
The Qt
object is a global object with utility functions, properties and enums.
It is not instantiable; to use it, call the members of the global Qt
object directly. For example:
import QtQuick 1.0 Text { color: Qt.rgba(1, 0, 0, 1) text: Qt.md5("hello, world") }
Enums
The Qt object contains the enums available in the Qt Namespace. For example, you can access the Qt::LeftButton and Qt::RightButton enum values as Qt.LeftButton
and Qt.RightButton
.
Types
The Qt object also contains helper functions for creating objects of specific data types. This is primarily useful when setting the properties of an item when the property has one of the following types:
color
- use Qt.rgba(), Qt.hsla(), Qt.darker(), Qt.lighter() or Qt.tint()rect
- use Qt.rect()point
- use Qt.point()size
- use Qt.size()vector3d
- use Qt.vector3d()
There are also string based constructors for these types. See QML Basic Types for more information.
Date/Time Formatters
The Qt object contains several functions for formatting QDateTime, QDate and QTime values.
- string Qt.formatDateTime(datetime date, variant format)
- string Qt.formatDate(datetime date, variant format)
- string Qt.formatTime(datetime date, variant format)
The format specification is described at Qt.formatDateTime.
Dynamic Object Creation
The following functions on the global object allow you to dynamically create QML items from files or strings. See Dynamic Object Management in QML for an overview of their use.
- object Qt.createComponent(url)
- object Qt.createQmlObject(string qml, object parent, string filepath)
Property Documentation
The application
object provides access to global application state properties shared by many QML components.
Its properties are:
application.active | This read-only property indicates whether the application is the top-most and focused application, and the user is able to interact with the application. The property is false when the application is in the background, the device keylock or screen saver is active, the screen backlight is turned off, or the global system dialog is being displayed on top of the application. It can be used for stopping and pausing animations, timers and active processing of data in order to save device battery power and free device memory and processor load when the application is not active. |
application.layoutDirection | 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.Possible values are:
|
The following example uses the application
object to indicate whether the application is currently active:
This QML property was introduced in QtQuick 1.1.