Results 1 to 6 of 6

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

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

    Qt Code:
    1. QMap<int, QString> mapCity;
    2. mapCity.insert(1,"one");
    3. mapCity.insert(2,"two");
    4. ...
    5. mapCity.insert(9,"nine");
    6. ...
    7.  
    8. //Now, I want delete 1,2,3.
    9.  
    10. QMap<int, QString>::Iterator it;
    11. for( it = mapCity.begin(); it != mapCity.end(); ++it)
    12. {
    13. if( it.key() < 4 )
    14. mapCity.remove( it ); //Is that OK??
    15. }
    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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.