Results 1 to 14 of 14

Thread: will Qt delete all dynamic data?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Jan 2006
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    3
    Thanked 2 Times in 1 Post

    Default Re: will Qt delete all dynamic data?

    Basically it depends upon how you create the object. It's not just sufficient to have a class inherit from a QObject for it to be managed by Qt. If you create an object and ensure that it has a parent then when the parent is deleted it will delete it's children.

    So in the example you gave mainWidget has the parent app, so when the application is closed then mainWidget will be freed. labelChild has the Widget as it's parent so when Widget is deleted it will ensure that labelChild is properly deleted. However, your pushButtons are not assigned any parent and so they will not be tidied up.

    You should see that your code as posted needs some modification but the changes are trivial. As a help put a qDebug() statement in your destructors, just so that you understand what is going on and that you are taking advantage of the auto deletion capabilities of Qt

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

    giowck (31st May 2010), somename (31st May 2010)

Similar Threads

  1. delete first row of data from .csv file?
    By babymonsta in forum Qt Programming
    Replies: 3
    Last Post: 20th May 2010, 04:39
  2. Replies: 4
    Last Post: 16th January 2010, 11:08
  3. Replies: 4
    Last Post: 4th September 2009, 09:33
  4. Replies: 4
    Last Post: 19th February 2009, 12:10
  5. Dynamic Data Display with OpenGL
    By showhand in forum Qt Programming
    Replies: 3
    Last Post: 14th March 2006, 02:17

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.