Results 1 to 8 of 8

Thread: How to destroy an object right

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to destroy an object right

    Ok I understand the heap advice. What's still not clear to me is that if I call delete MyFrame somewhere, is the destructor of the superclass also called or do I have to do it manually?

    And if so, actually how? I tried QFrame::~QFrame() and it didn't work.
    Last edited by Cruz; 22nd January 2009 at 11:01. Reason: spelling error

  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: How to destroy an object right

    Qt Code:
    1. ...
    2. delete myWidget;
    3. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to destroy an object right

    Quote Originally Posted by Cruz View Post
    Ok I understand the heap advice. What's still not clear to me is that if I call delete MyFrame somewhere, is the destructor of the superclass also called or do I have to do it manually?

    And if so, actually how? I tried QFrame::~QFrame() and it didn't work.
    See C++ FAQ Lite: [11.12] When I write a derived class's destructor, do I need to explicitly call the destructor for my base class?
    J-P Nurmi

  4. The following user says thank you to jpn for this useful post:

    Cruz (22nd January 2009)

Similar Threads

  1. Getting std::string object from QString object ( qt3)
    By joseph in forum Qt Programming
    Replies: 11
    Last Post: 28th March 2013, 20:09
  2. Help with Q_PROPERTY with object pointer
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2009, 17:31
  3. A form returning an object.
    By cbarmpar in forum Qt Programming
    Replies: 3
    Last Post: 8th September 2008, 05:21
  4. Object Not destroy
    By Sudhanshu Sharma in forum Qt Programming
    Replies: 3
    Last Post: 30th July 2008, 23:16
  5. Open a QMainWindow Object in QDialog Object
    By chuengchuenghq in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2008, 06:33

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.