i simply wanted customise this class because in some cases it is much comfortable, i wanted add 2 or 3 methods this is all.
You can always derive a custom class from QQuickItem and add more methods to it.
However the QQuickItem::childItems() will always return QList< QQuickItem * >. You need to do something like this:
QList< QQuickItem * > children = root->childItems();
QListIterator< QQuickItem * > it( children );
while ( it.hasNext() )
{
QQuickItem * pItem = it.next();
MyItem * pMyItem = qobject_cast< MyItem * >( pItem );
if ( pMyItem ) // check for NULL - if it is null, then the item was not a MyItem
{
pMyItem->callMyMethod();
}
}
QList< QQuickItem * > children = root->childItems();
QListIterator< QQuickItem * > it( children );
while ( it.hasNext() )
{
QQuickItem * pItem = it.next();
MyItem * pMyItem = qobject_cast< MyItem * >( pItem );
if ( pMyItem ) // check for NULL - if it is null, then the item was not a MyItem
{
pMyItem->callMyMethod();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks