- Qt 6.5
- Qt QML
- Qt 6.5.3 Reference Documentation

# Qt QML

The Qt QML module provides a framework for developing applications and libraries with the QML language. It defines and implements the language and engine infrastructure, and provides an API to enable application developers to extend the QML language with custom types and integrate QML code with JavaScript and C++. The Qt QML module provides both a QML API and a C++ API.

Note that while the Qt QML module provides the language and infrastructure for QML applications, the Qt Quick module provides many visual components, model-view support, an animation framework, and much more for building user interfaces.

If you're new to QML and Qt Quick, see QML Applications for an introduction to writing QML applications.

## Using the Module

### QML API

The QML types of the module are available through the `QtQml` import. To use the types, add the following import statement to your .qml file:

     import QtQml

### C++ API

Using a Qt module's C++ API requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake.

#### Building with CMake

Use the `find_package()` command to locate the needed module component in the `Qt6` package:

     find_package(Qt6 REQUIRED COMPONENTS Qml)
     target_link_libraries(mytarget PRIVATE Qt6::Qml)

For more details, see the Build with CMake overview.

To provide foreign QML type support for a non-QML library, locate the `QmlIntegration` module as follows:

     find_package(Qt6 REQUIRED COMPONENTS QmlIntegration)
     target_link_libraries(mytarget PRIVATE Qt6::QmlIntegration)

See qt6_generate_foreign_qml_types for details.

#### Building with qmake

To configure the module for building with qmake, add the module as a value of the `QT` variable in the project's .pro file:

     QT += qml

## QML and QML Types

The Qt QML module contains the QML framework and important QML types used in applications. The constructs of QML are described in the The QML Reference.

In addition to the QML Value Types, the module comes with the following QML object types:

- Component
- QtObject
- Binding
- Connections
- Timer

The Qt global object provides useful enums and functions for various QML types.

### Lists and Models

New in Qt 5.1, the model types are moved to a submodule, `QtQml.Models`. The Qt QML Models page has more information.

- DelegateModel
- DelegateModelGroup
- ListElement
- ListModel
- ObjectModel

## JavaScript Environment for QML Applications

JavaScript expressions allow QML code to contain application logic. Qt QML provides the framework for running JavaScript expressions in QML and from C++.

These sections are from The QML Reference.

- Integrating QML and JavaScript
- Using JavaScript Expressions with QML
- Dynamic QML Object Creation from JavaScript
- Defining JavaScript Resources In QML
- Importing JavaScript Resources In QML
- JavaScript Host Environment

## Integrating QML with C++ Applications

The module also provides the framework for running QML applications. The QML framework allows QML code to contain JavaScript expressions and for the QML code to interact with C++ code.

### Articles and Guides

- Overview - QML and C++ Integration
- Data Type Conversion Between QML and C++
- Integrating with JavaScript values from C++
- Exposing Attributes of C++ Types to QML
- Defining QML Types from C++
- Writing QML Modules
- Important C++ Classes Provided By The Qt QML Module

### Tutorials

- Writing QML Extensions with C++
- Writing advanced QML Extensions with C++

## Licenses and Attributions

Qt QML is available under commercial licenses from The Qt Company. In addition, it is available under free software licenses. Since Qt 5.4, these free software licenses are GNU Lesser General Public License, version 3, or the GNU General Public License, version 2. See Qt Licensing for further details.

Furthermore Qt QML in Qt 6.5.3 may contain third party modules under following permissive licenses:

JavaScriptCore Macro Assembler | BSD 2-clause "Simplified" License

## Related Articles and Guides

Further information for writing QML applications:

- The QML Reference
- Qt Quick Compiler - overview of Qt Quick Compiler components
- QML Applications - essential information for application development with QML and Qt Quick
- Qt Quick - a module which provides a set of QML types and C++ classes for building user interfaces and applications with QML
- The QML Disk Cache - how to fine tune if and where the QML engine caches compilation results

## Reference

- C++ Classes
- QML Types