本页面

Qt 3D

Qt 3D 提供了面向近实时仿真系统的功能,支持在 Qt C++ 和Qt Quick 应用程序中进行 2D 和 3D 渲染。

Qt 3D 中的功能分为以下 C++ 模块:

以下 C++ 模块尚在开发中,但已作为技术预览版提供:

对于Qt Quick 应用程序,Qt 3D 提供了以下 QML 模块:

以下 QML 模块尚在开发中,但已作为技术预览版提供:

使用模块

对于执行 2D 或 3D 渲染、碰撞检测并处理用户输入的 C++ 应用程序,请在代码中包含以下模块类的指令:

#include <Qt3DCore>
#include <Qt3DRender>
#include <Qt3DInput>
#include <Qt3DLogic>
#include <Qt3DExtras>
#include <Qt3DAnimation>

要将 QML 类型导入您的应用程序,请在 .qml 文件中使用以下导入语句:

import Qt3D.Core
import Qt3D.Render
import Qt3D.Input
import Qt3D.Logic
import Qt3D.Extras
import Qt3D.Animation
import QtQuick.Scene2D
import QtQuick.Scene3D

要使用 Qt 模块的 C++ API,需要链接到该模块库,可以是直接链接,也可以通过其他依赖项间接链接。包括CMake和qmake 在内的多种构建工具都提供了对此的专门支持。

使用 CMake 构建

使用find_package() 命令在Qt6 包中定位所需的模块组件:

find_package(Qt6 REQUIRED COMPONENTS
    3DCore
    3DRender
    3DInput
    3DLogic
    3DExtras
    3DAnimation
)
target_link_libraries(mytarget PRIVATE
    Qt6::3DCore
    Qt6::3DRender
    Qt6::3DLogic
    Qt6::3DExtras
    Qt6::3DAnimation
)

使用 qmake 构建

要配置模块以便使用 qmake 进行构建,请在项目的 .pro 文件中将模块添加到QT 变量中:

QT += 3dcore 3drender 3dinput 3dlogic 3dextras 3danimation

Qt Quick 应用程序需要额外的依赖项:

QT += 3dcore 3drender 3dinput 3dlogic 3dextras 3danimation qml quick 3dquick

概述

Qt 3D 的高层设计和开发动机在《Qt 3D 概述》中有所描述。Qt 3D 渲染功能支持数据驱动的配置,详情请参阅《Qt 3D 渲染帧图》。

参考

Qt 3D 平台支持

Qt 3D 支持以下平台:

  • Microsoft Windows (win32) - 已支持
  • Linux X11 - 已支持
  • macOS - 已支持,但可能会存在一些视网膜屏幕缩放问题
  • Android - 支持
  • 嵌入式 Linux - 支持
  • iOS - 自(Qt 5.7)起支持
  • WinRT - 尚未支持

模块演变

“Qt3D 的变更”列出了针对 Qt 6 系列所做的模块 API 和功能方面的重大变更。

许可与归属

Qt 3D 本模块由The Qt Company 提供商业许可。此外,它还遵循GNU 较少通用公共许可证第 3 版(LGPLv3)或GNU 通用公共许可证第 2 版(GPLv2)。更多详细信息请参阅Qt 许可说明。

此外,Qt 3D 中包含遵循以下宽松许可协议的第三方模块:

Dear ImGui - ProggyClean.ttf

MIT 许可

Dear ImGui - stb

MIT 许可或公有领域

Dear ImGui, version v1.91.0

MIT 许可

Open Asset Import Library, version 6.0.5

BSD 3 条款“新”或“修订”许可

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