Results 1 to 2 of 2

Thread: delete

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default delete

    Hi, Do I have to call 'delete' in anywhere? (eg. destructor)? thanks. Or Does qt provide it to itself? Does it do this for every widgets?
    Qt Code:
    1. std::vector <FancyPopup*> ppop; //member of Mainform class
    2. //inside constructor of Mainform class
    3. for (int i=0; i<8; i++)
    4. ppop.push_back(new FancyPopup(this));
    To copy to clipboard, switch view to plain text mode 
    Regards

  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

    You don't have to (but you can). Every QObject (i.e. widget too) which has a parent will be deleted when its parent is destroyed.

    In this case all FancyPopup instances will be deleted when you destroy Mainform (note that this also means that they won't be deleted if you won't destroy Mainform).

  3. The following 2 users say thank you to jacek for this useful post:

    aMan (13th July 2006), gfunk (13th July 2006)

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. a simple question .how to delete a treewidgetitem
    By Alina in forum Qt Programming
    Replies: 6
    Last Post: 20th February 2006, 10:18
  4. Basic question on new and delete
    By jcr in forum General Programming
    Replies: 25
    Last Post: 14th February 2006, 15:09
  5. 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.