本页内容

Qt3DCore::QComponent Class

class Qt3DCore::QComponent

可由Qt3DCore::QEntity 实例作为组件进行聚合的场景节点的基类。更多内容...

该类已弃用。我们强烈建议不要在新的代码中使用它。

属性

公共函数

QComponent(Qt3DCore::QNode *parent = nullptr)
QList<Qt3DCore::QEntity *> entities() const
bool isShareable() const

公共槽位

void setShareable(bool isShareable)

信号

void addedToEntity(Qt3DCore::QEntity *entity)
void removedFromEntity(Qt3DCore::QEntity *entity)
void shareableChanged(bool isShareable)

详细说明

Qt3DCore::QComponent 提供了一种行为的垂直切片,该切片可被分配给Qt3DCore::QEntity 实例,有时也可在这些实例之间共享。

Qt3DCore::QComponent 子类通常被聚合为组,从而为聚合实体赋予有用的行为。例如,要使一个实体能够被 Qt3D 渲染器方面绘制,该实体很可能聚合Qt3DCore::QTransform 、Qt3DRender::QMesh 和Qt3DRender::QMaterial 组件。

另请参阅 Qt3DCore::QEntity 。

属性文档

isShareable : bool

保存QComponent 的可共享标志。如果true ,则QComponent 可在多个实体之间共享。

访问函数:

bool isShareable() const
void setShareable(bool isShareable)

通知器信号:

void shareableChanged(bool isShareable)

成员函数文档

[explicit] QComponent::QComponent(Qt3DCore::QNode *parent = nullptr)

创建一个以parent 为父组件的新QComponent实例。

注意: 切勿直接实例化QComponent ,而应实例化其 子类之一。

[signal] void QComponent::addedToEntity(Qt3DCore::QEntity *entity)

表示已向entity 添加了一个引用。

QList<Qt3DCore::QEntity *> QComponent::entities() const

返回一个QList ,其中包含所有引用此组件的实体。

[signal] void QComponent::removedFromEntity(Qt3DCore::QEntity *entity)

表示已从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.