Results 1 to 4 of 4

Thread: Delete all members in a QGraphicsItemGroup

  1. #1
    Join Date
    Aug 2006
    Posts
    5
    Thanks
    4

    Question Delete all members in a QGraphicsItemGroup

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Delete all members in a QGraphicsItemGroup

    Maybe something like:
    Qt Code:
    1. foreach( QGraphicsItem *item, _scene->items( group->boundingRect() ) ) {
    2. if( item->group() == group ) {
    3. delete item;
    4. }
    5. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to jacek for this useful post:

    vmferreira (17th August 2006)

  4. #3
    Join Date
    Aug 2006
    Posts
    5
    Thanks
    4

    Default Re: Delete all members in a QGraphicsItemGroup

    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..

  5. #4
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Delete all members in a QGraphicsItemGroup

    Quote Originally Posted by vmferreira
    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!
    Software Engineer



Similar Threads

  1. When is the best time to delete a QCanvasItem
    By irudkin in forum Qt Programming
    Replies: 12
    Last Post: 8th March 2007, 21:28
  2. delete items from list box
    By vvbkumar in forum Qt Programming
    Replies: 4
    Last Post: 23rd June 2006, 19:08
  3. Basic question on new and delete
    By jcr in forum General Programming
    Replies: 25
    Last Post: 14th February 2006, 15:09
  4. How to explicitely delete a QDir?
    By alan in forum Newbie
    Replies: 2
    Last Post: 13th February 2006, 17:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.