Qt Qml QML Types

Qt Qml模块提供了可与 QML 语言一起使用的各种方便类型的定义和实现。这包括基本 QML 类型,可为进一步扩展 QML 语言提供基础。QtObjectComponent 对象类型是非可视的,为 QML 的扩展提供了基石。

导入 QtQml

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

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

import QtQml

许多客户永远不需要直接使用QtQml 模块,而是通过QtQuick 模块间接导入,如下所示:

import QtQuick

有关 Qt Quick模块文档,了解有关其类型的更多信息。

用于创建列表和模型的 QML 类型,如ListModelListElement ,属于子模块QtQml.Models

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

只要导入QtQml ,就会自动导入QtQml.ModelsQtQml.WorkerScript 。它们的所有类型也都可用。

Qt Quick模块会自动导入QtQml 以及QtQml.ModelsQtQml.WorkerScript ,只要导入QtQuick ,它们的所有类型都可用。

值类型

提供了以下QML 值类型

point

带 x 和 y 属性的值

rect

带 x、y、宽度和高度属性的值

size

具有宽度和高度属性的值

序列类型

除了与每个值类型和对象类型一起注册的类型外,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

描述与信号的通用连接

Date

提供日期函数

Locale

提供本地特定属性和格式化数据

LoggingCategory

在 QML 中定义日志类别

Number

提供代表数字值的对象

Qt

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

QtObject

基本的 QML 类型

Timer

在指定时间间隔触发处理程序

XMLHttpRequest

向服务器发送请求的对象

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