QAspectEngine Class

class Qt3DCore::QAspectEngine

Responsible for handling all the QAbstractAspect subclasses that have been registered with the scene. More...

Header: #include <Qt3DCore/QAspectEngine>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3dcore)
target_link_libraries(mytarget PRIVATE Qt6::3dcore)
qmake: QT += 3dcore
Since: Qt 5.7
Inherits: QObject

Public Types

enum RunMode { Manual, Automatic }

Public Functions

QAspectEngine(QObject *parent = nullptr)
virtual ~QAspectEngine()
Qt3DCore::QAbstractAspect *aspect(const QString &name) const
QList<Qt3DCore::QAbstractAspect *> aspects() const
QVariant executeCommand(const QString &command)
Qt3DCore::QNode *lookupNode(Qt3DCore::QNodeId id) const
QList<Qt3DCore::QNode *> lookupNodes(const QList<Qt3DCore::QNodeId> &ids) const
void processFrame()
void registerAspect(Qt3DCore::QAbstractAspect *aspect)
void registerAspect(const QString &name)
Qt3DCore::QEntityPtr rootEntity() const
Qt3DCore::QAspectEngine::RunMode runMode() const
void setRootEntity(Qt3DCore::QEntityPtr root)
void setRunMode(Qt3DCore::QAspectEngine::RunMode mode)
void unregisterAspect(Qt3DCore::QAbstractAspect *aspect)
void unregisterAspect(const QString &name)

Detailed Description

The Qt3D run loop is controlled by the Qt3DRender::QAspectEngine.

Qt3DCore::QAbstractAspect subclasses can be registered by calling Qt3DCore::QAspectEngine::registerAspect() which will take care of registering the aspect and in turn that will call Qt3DCore::QAbstractAspect::onRegistered();

The simulation loop is launched as soon as a root Qt3DCore::QEntity is set on the Qt3DCore::QAspectEngine. This is followed by a call to onEngineStartup() on each aspect so that they can start their simulation work.

The simulation loop is stopped when the root entity is set to Qt3DCore::QEntityPtr(). This calls onEngineShutdown() on each aspect so that they can stop performing their simulation work.

Setting a new valid root entity would restart the simulation loop again.

Member Type Documentation

enum QAspectEngine::RunMode

Member Function Documentation

QAspectEngine::QAspectEngine(QObject *parent = nullptr)

Constructs a new QAspectEngine with parent.

[virtual] QAspectEngine::~QAspectEngine()

Destroys the engine.

Qt3DCore::QAbstractAspect *QAspectEngine::aspect(const QString &name) const

Returns the asepect matching the name

Note: Required that the aspect was registered by name

QList<Qt3DCore::QAbstractAspect *> QAspectEngine::aspects() const

Returns the aspects owned by the aspect engine.

QVariant QAspectEngine::executeCommand(const QString &command)

Executes the given command on aspect engine. Valid commands are:

  • "list aspects"

Returns the reply for the command.

Qt3DCore::QNode *QAspectEngine::lookupNode(Qt3DCore::QNodeId id) const

QList<Qt3DCore::QNode *> QAspectEngine::lookupNodes(const QList<Qt3DCore::QNodeId> &ids) const

void QAspectEngine::processFrame()

If using the manual run mode, this function executes the jobs for each aspect. It is blocking and won't return until all jobs have been completed.

If you are using the QRenderAspect,

void QAspectEngine::registerAspect(Qt3DCore::QAbstractAspect *aspect)

Registers a new aspect to the AspectManager. The QAspectEngine takes ownership of the aspect and will delete it when the aspect is unregistered.

void QAspectEngine::registerAspect(const QString &name)

Registers a new aspect to the AspectManager based on its name Uses the currently set aspect factory to create the actual aspect instance.

Qt3DCore::QEntityPtr QAspectEngine::rootEntity() const

Returns the root entity of the aspect engine.

See also setRootEntity().

Qt3DCore::QAspectEngine::RunMode QAspectEngine::runMode() const

See also setRunMode().

void QAspectEngine::setRootEntity(Qt3DCore::QEntityPtr root)

Sets the root entity for the aspect engine.

See also rootEntity().

void QAspectEngine::setRunMode(Qt3DCore::QAspectEngine::RunMode mode)

See also runMode().

void QAspectEngine::unregisterAspect(Qt3DCore::QAbstractAspect *aspect)

Unregisters and deletes the given aspect.

void QAspectEngine::unregisterAspect(const QString &name)

Unregisters and deletes the aspect with the given name.

Related Non-Members


A shared pointer for QEntity.

© 2022 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.