Qt 3D Render QML Types
自 Qt3D.Render 6.8 起,该模块已弃用。我们强烈建议不要在新代码中使用它。
要导入并使用该模块的 QML 类型,请使用以下语句:
import Qt3D.Render 2.12选择渲染后端
Render 组件提供了两种渲染后端。
- OpenGL 后端(ES 2、ES 3.2、GL 2、GL 3、GL 3.2、GL 4.3)
- RHI 后端(ES 2、GL、DirectX、Vulkan、Metal)
如果您仅针对 OpenGL 开发且使用了特定的 OpenGL 功能,建议使用 OpenGL 后端。这是Qt 3D 在 Qt 5 系列中专用的 OpenGL 后端。
如果您未使用特定的 OpenGL 功能,且希望支持可能已弃用 OpenGL 的不同平台,则使用 RHI 后端是一个更好的选择。
要选择渲染后端,需将环境变量 QT3D_RENDERER 设置为 "opengl" 或 "rhi"。默认使用 OpenGL 后端。
使用 RHI 后端时,您可以通过将 QSG_RHI_BACKEND 设置为以下值之一,进一步强制使用内部 RHI 后端:
- opengl -> RHI OpenGL 后端
- gl -> RHI OpenGL 后端
- gles2 -> RHI OpenGL 后端
- metal -> RHI Metal 后端
- vulkan -> RHI Vulkan 后端
- d3d11 -> RHI DirectX 11 后端
如果未指定,RHI 将默认采用其推断出的该平台最佳后端。
此外,如果使用QQuickWindow ,可以使用QQuickWindow::setGraphicsApi()来指定RHI的内部渲染后端。
© 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.