Qt 3D

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

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

以下 C++ 模块仍在开发中,但可作为技术预览版使用:

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

以下 QML 模块仍在开发中,但可作为技术预览版使用:

使用模块

对于执行二维或三维渲染、碰撞检测和处理用户输入的 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 需要直接或通过其他依赖关系与模块库链接。有几种构建工具专门支持这一点,包括CMakeqmake

使用 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 Render 支持数据驱动配置,详见Qt 3D Render Framegraph

参考资料

Qt 3D 平台支持

Qt 3D 支持以下平台:

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

模块演变

Qt3D 的变更列出了Qt6 系列中模块 API 和功能的重要变更。

许可证和归属

Qt 3D Qt3D 是根据Qt 公司的商业许可提供的。此外,它还可以在GNU Lesser General Public License 第 3 版GNU General Public License 第 2 版下使用。详情请参见Qt Licensing

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

Dear ImGui - ProggyClean.ttf

MIT 许可

Dear ImGui - stb

MIT 许可或公共领域

Dear ImGui, version v1.91.0

MIT 许可

Open Asset Import Library, version 5.4.3

BSD 3 条款 "新 "或 "修订 "许可证

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