diff --git a/src/controls/QskQuick.h b/src/controls/QskQuick.h index c849c083..923fad3b 100644 --- a/src/controls/QskQuick.h +++ b/src/controls/QskQuick.h @@ -8,6 +8,7 @@ #include "QskGlobal.h" #include +#include class QQuickItem; class QSGNode; @@ -43,4 +44,16 @@ QSK_EXPORT void qskInputMethodSetVisible( const QQuickItem*, bool ); QSK_EXPORT const QSGNode* qskItemNode( const QQuickItem* ); QSK_EXPORT const QSGNode* qskPaintNode( const QQuickItem* ); +template< typename Item > +inline Item qskAncestorOf( const QQuickItem* item ) +{ + for ( auto it = item; it != nullptr; it = it->parentItem() ) + { + if ( auto ancestor = qobject_cast< Item >( it ) ) + return ancestor; + } + + return nullptr; +} + #endif