QML 基本类型

QML 支持许多基本类型。

A 基本类型 is one that refers to a simple value, such as an int string . This contrasts with a QML Objects in Qt , which refers to an object with properties, signals, methods and so on. Unlike an object type, a basic type cannot be used to declare QML objects: it is not possible, for example, to declare an int{} object or a size{} 对象。

Basic types can be used to refer to a single value (e.g. int refers to a single number, string refers to a single free form text string in quotes).

When a variable or property holds a basic type and it is assigned to another variable or property, then a copy of the value is made. In JavaScript, this value is called a primitive value.


Some basic types are supported by the engine by default and do not require an import statement to be used, while others do require the client to import the module which provides them. All of the basic types listed below may be used as a property type in a QML document

由 QML 语言提供的基本类型

The basic types supported natively in the QML language are listed below:


二进制 true/false 值






Whole number, e.g. 0, 10, or -20






由 QML 模块提供的基本类型

QML modules may extend the QML language with more basic types. For example, the basic types provided by the QtQuick module are listed below:

Qt global object provides useful functions for manipulating values of basic types.

Currently only QML modules which are provided by Qt may provide their own basic types, however this may change in future releases of Qt QML. In order to use types provided by a particular QML module, clients must import that module in their QML documents.

另请参阅 QML Type System in Qt .