diff options
Diffstat (limited to 'src/core/nodes/qentity.h')
-rw-r--r-- | src/core/nodes/qentity.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/nodes/qentity.h b/src/core/nodes/qentity.h index dc7dc62c1..ef6aedc4d 100644 --- a/src/core/nodes/qentity.h +++ b/src/core/nodes/qentity.h @@ -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); |