qskAncestor added

This commit is contained in:
Uwe Rathmann 2019-03-15 15:39:27 +01:00
parent 4c3a171c46
commit d99844843b

View File

@ -8,6 +8,7 @@
#include "QskGlobal.h"
#include <qnamespace.h>
#include <qquickitem.h>
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