QComponent Class | Qt 3D 5.12.10

- Qt 5.12
- Qt 3D
- C++ Classes
- QComponent
- Qt 5.12.10 Reference Documentation

# QComponent Class

(Qt3DCore::QComponent)

The base class of scene nodes that can be aggregated by Qt3DCore::QEntity instances as a component. More...

Header: | #include <QComponent>
qmake: | QT += 3dcore
Since: | Qt 5.5
Instantiated By: | Component3D
Inherits: | Qt3DCore::QNode
Inherited By: | Qt3DAnimation::QAbstractClipAnimator, Qt3DCore::QArmature, Qt3DCore::QTransform, Qt3DInput::QAxisAccumulator, Qt3DInput::QInputSettings, Qt3DInput::QKeyboardHandler, Qt3DInput::QLogicalDevice, Qt3DInput::QMouseHandler, Qt3DLogic::QFrameAction, Qt3DRender::QAbstractLight, Qt3DRender::QAbstractRayCaster, Qt3DRender::QCameraLens, Qt3DRender::QComputeCommand, Qt3DRender::QEnvironmentLight, Qt3DRender::QGeometryRenderer, Qt3DRender::QLayer, Qt3DRender::QLevelOfDetail, Qt3DRender::QMaterial, Qt3DRender::QObjectPicker, Qt3DRender::QRenderSettings, Qt3DRender::QRenderTarget, Qt3DRender::QSceneLoader, and Qt3DRender::QShaderData

- List of all members, including inherited members
- Obsolete members

## Properties

- isShareable : bool

- 3 properties inherited from Qt3DCore::QNode
- 1 property inherited from QObject

## Public Functions

| QComponent(Qt3DCore::QNode *parent = nullptr)
virtual | ~QComponent()
QVector<Qt3DCore::QEntity *> | entities() const
bool | isShareable() const

- 13 public functions inherited from Qt3DCore::QNode
- 31 public functions inherited from QObject

## Public Slots

void | setShareable(bool isShareable)

- 3 public slots inherited from Qt3DCore::QNode
- 1 public slot inherited from QObject

## Signals

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

- 4 signals inherited from Qt3DCore::QNode
- 2 signals inherited from QObject

## Static Public Members

const QMetaObject | staticMetaObject

- 9 static public members inherited from QObject

### Additional Inherited Members

- 2 protected functions inherited from Qt3DCore::QNode
- 9 protected functions inherited from QObject

## Detailed Description

The base class of scene nodes that can be aggregated by Qt3DCore::QEntity instances as a component.

A Qt3DCore::QComponent provides a vertical slice of behavior that can be assigned to and sometimes shared across Qt3DCore::QEntity instances.

Qt3DCore::QComponent subclasses are often aggregated in groups that impart useful behavior to the aggregating entity. For example, to have an Entity that gets drawn by the Qt3D renderer aspect, an entity would most likely aggregate Qt3DCore::QTransform, Qt3DRender::QMesh, and Qt3DRender::QMaterial components.

See also Qt3DCore::QEntity.

## Property Documentation

### isShareable : bool

Holds the shareable flag of the QComponent. The QComponent can be shared across several entities if `true`.

Access functions:

bool | isShareable() const
void | setShareable(bool isShareable)

Notifier signal:

void | shareableChanged(bool isShareable)

## Member Function Documentation

### QComponent::QComponent(Qt3DCore::QNode *parent = nullptr)

Constructs a new QComponent instance with parent as the parent.

Note: a QComponent should never be instanced directly, instance one of the subclasses instead.

### `[virtual]` QComponent::~QComponent()

Destroys the instance of QComponent. The destructor is virtual.

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

Indicates that a reference has been added to entity.

### QVector<Qt3DCore::QEntity *> QComponent::entities() const

Returns a QVector containing all the entities that reference this component.

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

Indicates that a reference has been removed from entity.