That problem occurs due to a memory cleanup mess-up by your compiler. Qt encourages you to always allocate any QWidget and QWidget-derived object (QPushButton, QTextEdit, etc.) dynamically, with operator new.

In principle you must delete a widget that you have created with new. There is an exception to this rule: If you create a widget with a parent (or put it in a layout, which will give it a parent too), you do not need to delete it manually, as the parent widget deletes its children on its own destruction. So, in practice you will usually only need to delete the toplevel widget (dialog, mainwindow, etc)