Be careful!
Qt Code:
{ MyMainWindow w; QMainWindow w1; ... w1.setCentralWidget(&w); // w1 becomes w's parent w1.show(); } // (*)To copy to clipboard, switch view to plain text mode
(*) First "w1" goes out of scope and deletes its children, including "w". Then "w", which was already deleted by its parent ("w1"), goes out of scope => crash!





Reply With Quote
Bookmarks