PDA

View Full Version : Delete all members in a QGraphicsItemGroup



vmferreira
14th August 2006, 23:34
Hi, I'd like to know if there is a way to delete all members in a QGraphicsItemGroup, without delete it.
I created a class that inherits QGraphicsItemGroup, with a lot more data. So, I would like to keep this data, but delete all itens inside this QGraphicsItemGroup.. :)
Thanks

jacek
16th August 2006, 21:16
Maybe something like:
foreach( QGraphicsItem *item, _scene->items( group->boundingRect() ) ) {
if( item->group() == group ) {
delete item;
}
}

vmferreira
17th August 2006, 19:36
Thanks, but I've done by different ways

I reimplemented the addItem method in QGraphicsItemGroup, so now I have a QList<QGraphicItem *> which holds all members.. soh, I delete them by iteration..

gfunk
17th August 2006, 19:47
I reimplemented the addItem method in QGraphicsItemGroup, so now I have a QList<QGraphicItem *> which holds all members.. soh, I delete them by iteration..

Sounds like you can use qDeleteAll(list) then, no need to clutter up code with iteration loops! :D