diff options
Diffstat (limited to 'tests/auto/client/shared/corecompositor.h')
-rw-r--r-- | tests/auto/client/shared/corecompositor.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/client/shared/corecompositor.h b/tests/auto/client/shared/corecompositor.h index 875b7d050..254465ee6 100644 --- a/tests/auto/client/shared/corecompositor.h +++ b/tests/auto/client/shared/corecompositor.h @@ -125,6 +125,23 @@ public: } /*! + * \brief Returns the nth global with the given type, if any + */ + template<typename global_type> + global_type *get(int index) + { + warnIfNotLockedByThread(Q_FUNC_INFO); + for (auto *global : qAsConst(m_globals)) { + if (auto *casted = qobject_cast<global_type *>(global)) { + if (index--) + continue; + return casted; + } + } + return nullptr; + } + + /*! * \brief Returns all globals with the given type, if any */ template<typename global_type> |