The QML Type System
The types which may be used in the definition of an object hierarchy in a QML document can come from various sources. They may be:
- provided natively by the QML language
- registered via C++ by QML modules
- provided as QML documents by QML modules
Furthermore, application developers can provide their own types, either by registering C++ types directly, or by defining reusable components in QML documents which can then be imported.
Wherever the type definitions come from, the engine will enforce type-safety for properties and instances of those types.
QML Object Types
A QML object type is a type from which a QML object can be instantiated. QML object types are derived from QtObject, and are provided by QML modules. Applications can import these modules to use the object types they provide. The QtQuick module provides the most common object types needed to create user interfaces in QML.
Finally, every QML document implicitly defines a QML object type, which can be re-used in other QML documents. See the documentation about object types in the QML type system for in-depth information about object types.
QML Value Types
The QML language has built-in support for various primitive types including integers, double-precision floating point numbers, strings, and boolean values. Objects may have properties of these types, and values of these types may be passed as arguments to methods of objects.
See the QML Value Types documentation for more information about value types.
QML Sequence Types
Sequence types can be used to store sequences of values or objects.
See the documentation about sequence types in the QML type system for in-depth information about sequence types.
Enumerations
Enumerations are treated as special properties of types in QML.
See the the documentation about QML Enumerations for in-depth information about enumerations.
Singleton Types
QML supports singleton types, which provide a way to define a type of which only one instance exists in each QML engine. Singleton types are useful for providing application-wide state or functionality.
See Singletons in QML for more details.
Attached Types
Attached properties and signal handlers allow types to provide additional properties and signals that can be attached to other objects. This is a powerful mechanism for adding contextual information to QML objects.
See QML Attached Types for more details.
QML Namespaces
QML Namespaces can be used to expose enumerations from C++ namespaces.
See the documentation about namespaces in the QML type system for in-depth information about namespaces.
JavaScript Types
JavaScript objects and arrays are supported by the QML engine. Any standard JavaScript type can be created and stored using the generic var type.
For example, the standard Date and Array types are available, as below:
import QtQuick
Item {
property var theArray: []
property var theDate: new Date()
Component.onCompleted: {
for (var i = 0; i < 10; i++)
theArray.push("Item " + i)
console.log("There are", theArray.length, "items in the array")
console.log("The time is", theDate.toUTCString())
}
}See JavaScript Expressions in QML Documents for more details.
C++ Integration
Data Type Conversion Between QML and C++
When integrating QML with C++, data often needs to be transferred between the two environments. The QML engine provides automatic conversion between QML and C++ types for common data types, while custom types require explicit registration.
See Data Type Conversion Between QML and C++ for more details.
Interacting with QML Objects from C++
C++ code can access and manipulate QML objects by obtaining references to them from the QML engine. This allows C++ code to read and write properties, invoke methods, and connect to signals on QML objects.
See Interacting with QML Objects from C++ for more details.
Integrating with JavaScript Values from C++
The QML engine represents JavaScript values using the QJSValue and related classes, which allows C++ code to work with JavaScript objects, functions, and primitive values. This enables seamless integration between C++ and JavaScript code.
See Integrating with JavaScript values from C++ for more details.
Embedding C++ Objects into QML with Context Properties
Context properties should be avoided. See Embedding C++ Objects into QML with Context Properties for more details.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.