diff options
Diffstat (limited to 'src/core/nodes/qentity.h')
-rw-r--r-- | src/core/nodes/qentity.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/core/nodes/qentity.h b/src/core/nodes/qentity.h index f6044ce5e..f1a369c48 100644 --- a/src/core/nodes/qentity.h +++ b/src/core/nodes/qentity.h @@ -53,7 +53,7 @@ class QEntityPrivate; typedef QVector<QComponent*> QComponentVector; -class QT3DCORESHARED_EXPORT QEntity : public QNode +class Q_3DCORESHARED_EXPORT QEntity : public QNode { Q_OBJECT public: @@ -62,6 +62,19 @@ public: QComponentVector components() const; + template<class T> + QVector<T *> componentsOfType() const + { + QVector<T*> matchComponents; + const QComponentVector components = this->components(); + for (QComponent *component : components) { + T *typedComponent = qobject_cast<T*>(component); + if (typedComponent != nullptr) + matchComponents.append(typedComponent); + } + return matchComponents; + } + void addComponent(QComponent *comp); void removeComponent(QComponent *comp); |