Results 1 to 3 of 3

Thread: [SOLVED] Automatic children freeing for objects derived from QObject

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Automatic children freeing for objects derived from QObject

    Quote Originally Posted by hickscorp View Post
    will QT handle this itself when "destructing" the parent QTreeWidget?
    Yes, it will:
    Qt Code:
    1. #include <QObject>
    2. #include <QtDebug>
    3.  
    4. class Test : public QObject
    5. {
    6. public:
    7. Test( QObject * parent = 0 ) : QObject( parent ) { qDebug() << "Test::Test()"; }
    8. ~Test() { qDebug() << "Test::~Test()"; }
    9. };
    10.  
    11. int main()
    12. {
    13. Test *t1 = new Test();
    14. Test *t2 = new Test( t1 );
    15.  
    16. delete t1;
    17.  
    18. return 0;
    19. }
    To copy to clipboard, switch view to plain text mode 
    Result:
    Test::Test()
    Test::Test()
    Test::~Test()
    Test::~Test()

  2. The following user says thank you to jacek for this useful post:

    hickscorp (6th December 2006)

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.