Results 1 to 6 of 6

Thread: How to use QMap::remove() to delete some item?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    849
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6
    Thanked 163 Times in 151 Posts

    Default Re: How to use QMap::remove() to delete some item?

    Qt Code:
    1. QMap<int, QString>::Iterator it;
    2. for( it = mapCity.begin(); it != mapCity.end(); ) // remove increment here
    3. {
    4. if( it.key() < 4 )
    5. mapCity.remove( it++ ); // this is ok; note POSTFIX operator here
    6. else
    7. ++it;
    8. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 18th September 2008 at 07:32. Reason: missing [code] tags

Similar Threads

  1. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 19:21
  2. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:37
  3. Replies: 3
    Last Post: 4th April 2008, 19:51
  4. Replies: 1
    Last Post: 19th April 2007, 22:23
  5. c++, placement delete upon exception
    By stinos in forum General Programming
    Replies: 6
    Last Post: 31st October 2006, 15:38

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
  •  
Qt is a trademark of The Qt Company.