Qt3DCore::QEntity Class
class Qt3DCore::QEntityQt3DCore::QEntity 是一个Qt3DCore::QNode 的子类,可以聚合多个Qt3DCore::QComponent 实例,这些实例将决定其行为。更多内容...
| 头文件: | #include <QEntity> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS 3DCore) target_link_libraries(mytarget PRIVATE Qt6::3DCore) |
| qmake: | QT += 3dcore |
| 在 QML 中: | Entity |
| 继承自: | Qt3DCore::QNode |
| 被继承自: | Qt3DExtras::QAbstractCameraController、Qt3DExtras::QSkyboxEntity 、Qt3DExtras::QText2DEntity 以及Qt3DRender::QCamera |
| 状态: | 已弃用 |
该类已弃用。我们强烈建议不要在新代码中使用它。
公共函数
| QEntity(Qt3DCore::QNode *parent = nullptr) | |
| void | addComponent(Qt3DCore::QComponent *comp) |
| Qt3DCore::QComponentVector | components() const |
| QList<T *> | componentsOfType() const |
| Qt3DCore::QEntity * | parentEntity() const |
| void | removeComponent(Qt3DCore::QComponent *comp) |
相关的非成员
详细说明
Qt3DCore::QEntity 本身是一个空壳。Qt3DCore::QEntity 对象的行为由其引用的Qt3DCore::QComponent 对象定义。每个 Qt3D 后端组件都能通过识别实体由哪些组件构成来解释和处理该实体。某个组件可能决定仅处理由单个Qt3DCore::QTransform 组件构成的实体,而另一个组件则可能专注于Qt3DInput::QMouseHandler 。
另请参阅 Qt3DCore::QComponent 和Qt3DCore::QTransform 。
成员函数文档
[explicit] QEntity::QEntity(Qt3DCore::QNode *parent = nullptr)
创建一个新的Qt3DCore::QEntity 实例,其父对象为parent 。
void QEntity::addComponent(Qt3DCore::QComponent *comp)
向组件comp 添加一个新的引用。
注意:如果 Qt3DCore::QComponent 没有父组件,Qt3DCore::QEntity 将把自身设为其父组件,从而获得该组件的所有权。
Qt3DCore::QComponentVector QEntity::components() const
返回该实体引用的 Qt3DCore::QComponent 实例列表。
template <typename T> QList<T *> QEntity::componentsOfType() const
返回添加到该实体中且可转换为类型 T 的所有组件;如果没有此类组件,则返回一个空向量。
Qt3DCore::QEntity *QEntity::parentEntity() const
返回该实体的父级Qt3DCore::QEntity 实例。如果直接父级不是Qt3DCore::QEntity ,则该函数会向上遍历场景层次结构,直到找到父级Qt3DCore::QEntity 为止。如果找不到Qt3DCore::QEntity 父级,则返回null。
void QEntity::removeComponent(Qt3DCore::QComponent *comp)
删除了对comp 的引用。
© 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.