Qt QML

Qt QML模块为使用 QML 语言开发应用程序和库提供一个框架. 它定义和实现语言和引擎, 并提供一个API, 使应用程序开发人员能够使用自定义类型扩展QML语言, 并将QML代码与JavaScript和C++集成. Qt QML模块同时提供 QML APIC++ API.

注意: Qt QML模块为QML应用程序提供语言和引擎, 而 Qt Quick 模块为构建用户界面提供多种视觉组件, 模型视图支持, 动画框架等.

如果你是QML和Qt Quick的新手, 关于如何编写QML应用程序参见 QML Applications.

开始使用

To include the definitions of the module's classes, use the following directive:


  #include <QtQml>

The QML types in Qt QML are available through the QtQML import. To use the types, add the following import statement to your .qml file:


  import QtQml 2.0

To link against the module, add this line to your qmake .pro file:


  QT += qml

QML和QML类型

Qt QML模块包含QML框架和QML类型. The QML Reference描述QML结构.

QML基本类型外, QML模块还包含以下模块:

The Qt 全局对象为各种QML类型提供有效的枚举和函数.

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.

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 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.

Additional Frameworks

Licenses and Attributions

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

Furthermore Qt QML potentially contains third party modules under following permissive licenses:

JavaScriptCore Macro Assembler

BSD 2-clause "Simplified" License

Guides and Other Information

Further information for writing QML applications:

  • The QML Reference
  • 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

Reference