本页内容

Qt Qml QML Types

该 Qt Qml 该模块提供了各种可与 QML 语言配合使用的便捷类型的定义和实现。其中包括基础的 QML 类型,这些类型可为 QML 语言的进一步扩展奠定基础。QtObject 和Component 对象类型属于非可视化类型,为 QML 的扩展提供了构建模块。

导入 QtQml

只有当 QML 文档导入了QtQml 命名空间(或如下面所述,导入了QtQuick 命名空间)时,QtQml 模块提供的类型才可在该文档中使用。

要使用该模块,请使用以下语句导入QtQml 模块:

import QtQml

许多客户端根本无需直接使用QtQml 模块,而是会通过QtQuick 模块间接导入它,具体如下:

import QtQuick

有关其类型的更多信息,请参阅 Qt Quick 模块文档以获取有关其类型的更多信息。

用于创建列表和模型的 QML 类型(例如ListModel 和ListElement )属于子模块QtQml.Models 。

WorkerScript QML 类型属于子模块QtQml.WorkerScript 。

每当您导入QtQml 时,QtQml.Models 和QtQml.WorkerScript 都会被自动导入。届时,它们的所有类型也将随之可用。

该 Qt Quick 该模块会自动导入QtQml ,并由此间接导入QtQml.Models 和QtQml.WorkerScript ,因此每当您导入QtQuick 时,所有相关类型均可供使用。

值类型

提供了以下QML 值类型:

easingCurve

表示缓动曲线的值

point

具有 x 和 y 属性的值

qmlProperty

引用对象属性的值

rect

具有 x、y、width 和 height 属性的值

size

具有 width 和 height 属性的值

序列类型

除了在每个值类型和对象类型中注册的序列类型外,Qt Qml 模块还提供了以下QML 序列类型:

  • std::vector<QString>
  • std::vector<QUrl>
  • std::vector<bool>
  • std::vector<int>
  • std::vector<float>
  • std::vector<double>

对象类型

提供了以下QML 对象类型:

Binding

支持任意创建属性绑定

Component

封装 QML 组件定义

Connections

描述与信号的通用连接

Easing

提供对缓动枚举和便捷 API 的访问

Locale

提供特定于区域设置的属性及格式化数据

LoggingCategory

在 QML 中定义日志记录类别

Qt

提供一个包含来自 Qt 的有用枚举和函数的全局对象

QtObject

一种基本的 QML 类型

Timer

在指定间隔触发处理程序

date

日期值

easingCurve

表示缓动曲线的值

point

包含 x 和 y 属性的值

qmlProperty

引用对象属性的值

rect

具有 x、y、width 和 height 属性的值

size

具有 width 和 height 属性的值

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