Results 1 to 3 of 3

Thread: Proper way to delete a QMap

  1. #1
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Proper way to delete a QMap

    Hi, I have a QMap filled with pointers to objects, and I'd like to ask what's the proper way to delete them.

    I planned to loop though the map and delete the items one by one... but I saw the "clear()" method.

    void QMap::clear ()
    Removes all items from the map.


    Does it means "clear()" will delete dynamic objects and free the memory?

    thanks!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Proper way to delete a QMap

    have a look at qDeleteAll.
    QMap::clear doesn't delete pointers.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Proper way to delete a QMap

    that's it.

    thanks!

Similar Threads

  1. Replies: 4
    Last Post: 19th February 2009, 11:10
  2. Best way for a graphicsitem to delete itself
    By pherthyl in forum Qt Programming
    Replies: 7
    Last Post: 22nd June 2008, 05:57
  3. c++, placement delete upon exception
    By stinos in forum General Programming
    Replies: 6
    Last Post: 31st October 2006, 15:38
  4. QMap Problem with arguments.
    By ankurjain in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2006, 12:12
  5. QMap destructor bug
    By Ruud in forum Qt Programming
    Replies: 6
    Last Post: 8th April 2006, 09:08

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.