From d99844843bebfeba14112261b37cc842e352167f Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Fri, 15 Mar 2019 15:39:27 +0100 Subject: [PATCH] qskAncestor added --- src/controls/QskQuick.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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