QML supports a number of basic types.
The basic type is a reference type single value, e.g. int, string. This QML ---- references that object type attribute, a signal, such as a function of a composite object (with reference to the difference between the class and int). Different object types can not be used to declare the type of the basic QML objects, e.g. int {} is not declared or size {} objects.
The basic type may be used:
A single value (e.g., int a simple figure, a simple list var)
Value (e.g., size having a width and height) of a simple pair of attribute values
The basic types of support
QML engine supported by default part of the base type, this part does not need to import the introduction of other types of modules can be used. Other types you need to import the module to provide them.
All of the following basic types can be used as a property types in QML file, in addition to these types of situations:
QML list must be used with the object type.
Enumeration can not be directly used because the enumeration must be defined by a registered QML object type.
QML provide basic types of
The following are the basic types supported by QML language itself:
bool value of true / false
double floating point, double precision store
enumeration named enumeration value
int integer, such as 0, 10, -20
list QML object list
real float
string free-form text string
Resource url path
var common attribute type
QML basic types of module
QML also provide some basic module to expand the type of QML language, such as, the type QtQuick basic module is shown below,
date Date
point having x, y targeting values
rect having x, y, width, height
size has a width, height
Qt global object provides some convenient functions for these basic types.
Currently, only Qt QML module itself can provide their basic types. This is, after Qt-QML version says may change. In order to use these particular QML basic types of modules, these modules must import user QML file.
The basic types of properties changes in behavior (Behanvior)
Some basic types have attributes (property), e.g., font has pixelSize, family, and the bold attribute. And the properties of different object types, the basic type of property does not provide its own properties change signal. You can create only one property change signal to the base type property itself. Such as,
Text{
// invalid
onFont.pixelSizeChanged: doSomething()
// also invalid
font {
onPixelSizeChanged: doSomething()
}
// but this is ok
onFontChanged: doSomething()
}
But, you know, when any change in the basic type of property and the property itself changes occur, will send a signal to change the property. The following code as an example:
Text{
onFontChanged: console.log("font changed")
Text{id: otherText}
focus: true
// changing any of the font attributes, or reassigning the property
// to a different font value, will invoke the onFontChanged handler
Keys.onDigit1Pressed: font.pixelSize += 1
Keys.onDigit2Pressed: font.b = !font.b
Keys.onDigit3Pressed: font = otherText.font
}
In contrast, the properties of the object type attribute is reset only emit their own property change signal values to different objects, and invokes the signal handler property changes.