Qt3DRender::Quick::QScene2D Class
class Qt3DRender::Quick::QScene2D该类支持将 QML 渲染为纹理,该纹理随后可作为 3D 场景的一部分使用。更多...
| 头文件: | #include <Qt3DQuickScene2D/QScene2D> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS 3dquickscene2d) target_link_libraries(mytarget PRIVATE Qt6::3dquickscene2d) |
| qmake: | QT += 3dquickscene2d |
| 在 QML 中: | Scene2D |
| 继承自: | Qt3DCore::QNode |
| 状态: | 已弃用 |
该类已弃用。我们强烈建议不要在新代码中使用它。
公共类型
| enum | RenderPolicy { Continuous, SingleShot } |
属性
- item : QQuickItem*
- mouseEnabled : bool
- output : Qt3DRender::QRenderTargetOutput*
- renderPolicy : RenderPolicy
公共函数
| QScene2D(Qt3DCore::QNode *parent = nullptr) | |
| void | addEntity(Qt3DCore::QEntity *entity) |
| QList<Qt3DCore::QEntity *> | entities() const |
| bool | isMouseEnabled() const |
| QQuickItem * | item() const |
| Qt3DRender::QRenderTargetOutput * | output() const |
| void | removeEntity(Qt3DCore::QEntity *entity) |
| Qt3DRender::Quick::QScene2D::RenderPolicy | renderPolicy() const |
公共槽位
| void | setItem(QQuickItem *item) |
| void | setMouseEnabled(bool enabled) |
| void | setOutput(Qt3DRender::QRenderTargetOutput *output) |
| void | setRenderPolicy(Qt3DRender::Quick::QScene2D::RenderPolicy policy) |
信号
| void | itemChanged(QQuickItem *item) |
| void | mouseEnabledChanged(bool enabled) |
| void | outputChanged(Qt3DRender::QRenderTargetOutput *output) |
| void | renderPolicyChanged(Qt3DRender::Quick::QScene2D::RenderPolicy policy) |
详细说明
该类使用QQuickRenderControl 将给定的QQuickItem 渲染到一个离屏表面上,该表面附着在用户提供的纹理上。这使得组件能够直接渲染到纹理中而无需中间复制,用户也可以自由指定纹理在3D场景中的使用方式。
使用 QScene2D 的实体可以与该类关联,以实现与该项的交互;如果某个实体带有QObjectPicker 组件,则该选择器的选择事件会被发送至 QScene2D,转换为鼠标事件,最后发送至该项。
注意:仅 支持鼠标事件。该项不支持键盘输入。
成员类型文档
enum QScene2D::RenderPolicy
此枚举类型描述了可用的渲染策略类型。
| 常量 | 值 | 描述 |
|---|---|---|
Qt3DRender::Quick::QScene2D::Continuous | 0 | Scene2D 正在持续渲染。这是默认的渲染策略。 |
Qt3DRender::Quick::QScene2D::SingleShot | 1 | Scene2D 仅渲染一次到纹理上,之后为渲染分配的资源将被释放。 |
属性文档
item : QQuickItem*
保存QQuickItem ,该对象由QScene2D 渲染到纹理上。
访问函数:
| QQuickItem * | item() const |
| void | setItem(QQuickItem *item) |
通知器信号:
| void | itemChanged(QQuickItem *item) |
mouseEnabled : bool
表示渲染项是否启用了鼠标事件。鼠标事件由添加到QScene2D 中的实体的对象选择事件生成。默认情况下,鼠标功能处于启用状态。
注意: 由于对象选择操作在后端进行,因此事件 会延迟一帧。
访问函数:
| bool | isMouseEnabled() const |
| void | setMouseEnabled(bool enabled) |
通知器信号:
| void | mouseEnabledChanged(bool enabled) |
output : Qt3DRender::QRenderTargetOutput*
保存 QRenderTargetOutput 对象,该对象指定了QScene2D 的渲染目标位置。
访问函数:
| Qt3DRender::QRenderTargetOutput * | output() const |
| void | setOutput(Qt3DRender::QRenderTargetOutput *output) |
通知器信号:
| void | outputChanged(Qt3DRender::QRenderTargetOutput *output) |
renderPolicy : RenderPolicy
保存此 Scene2D 的渲染策略。
访问函数:
| Qt3DRender::Quick::QScene2D::RenderPolicy | renderPolicy() const |
| void | setRenderPolicy(Qt3DRender::Quick::QScene2D::RenderPolicy policy) |
通知器信号:
| void | renderPolicyChanged(Qt3DRender::Quick::QScene2D::RenderPolicy policy) |
成员函数文档
[explicit] QScene2D::QScene2D(Qt3DCore::QNode *parent = nullptr)
该构造函数会使用指定的parent 创建一个新的QScene2D实例。
void QScene2D::addEntity(Qt3DCore::QEntity *entity)
向QScene2D 对象添加一个entity 。如果实体具有QObjectPicker,则该实体的选中事件将发送至QScene2D 并转换为鼠标事件。
QList<Qt3DCore::QEntity *> QScene2D::entities() const
检索与QScene2D 关联的实体。
void QScene2D::removeEntity(Qt3DCore::QEntity *entity)
从QScene2D 对象中移除一个entity 。
© 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.