Qt Quick 3D

Qt Quick 3D 提供了一个高级应用程序接口,用于创建 3D 内容和 3D 用户界面。 Qt Quick.Qt Quick 3D 不使用会产生同步问题和额外抽象层的外部引擎,而是为现有的Qt Quick 空间内容场景图提供扩展,并为该扩展场景图提供渲染器。使用空间场景图时,可以将 Qt Quick 2D 内容与 3D 内容混合使用。

Qt Quick 3D 还可通过Qt Quick 3D Xr 实现 XR 和 VR 应用。

使用模块

QML API

模块的 QML 类型可通过QtQuick3D 导入。要使用这些类型,请在 .qml 文件中添加以下导入语句:

import QtQuick3D

以下模块导入提供了附加功能:

import QtQuick3D.AssetUtils
import QtQuick3D.Helpers
import QtQuick3D.Particles3D
import QtQuick3D.Xr

C++ API

使用 Qt 模块的 C++ API 需要直接或通过其他依赖项与模块库链接。一些编译工具对此提供了专门支持,包括CMakeqmake

使用 CMake 构建

使用find_package() 命令在Qt6 软件包中找到所需的模块组件:

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

更多详情,请参阅使用 CMake 构建概述。

使用 qmake 构建

要配置模块以便用 qmake 构建,请在项目的 .pro 文件中添加模块作为QT 变量的值:

QT += quick3d

从源代码编译

从源代码构建时,请确保首先构建了qtdeclarativeqtshadertools软件源中的模块和工具,因为没有这些模块和工具,就无法使用Qt Quick 3D。同时强烈建议使用qtquicktimeline,否则将无法使用基于关键帧的动画。

此外,一些示例依赖于 Qt Quick Controls.

模块演变

Qt Quick 3D 的变更列出了 Qt 6 系列 Qt 在模块 API 和功能方面的重要变更。

文章和指南

实例

参考资料

Qt 学院课程

许可和归属

Qt Quick 3D 可在Qt Company 的商业许可下使用。此外,它还受GNU 通用公共许可证第 3 版的保护。有关详细信息,请参阅Qt 许可

此外,Qt Quick 3D 可能包含以下许可下的第三方模块:

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