PDA

View Full Version : Qt::WA_DeleteOnClose not on by default



scarecr0w132
7th June 2015, 13:03
Why does QWidget not have Qt::WA_DeleteOnClose attribute on by default? Ie Why is the widget not deleted when the widget is closed (On the heap)?

ChrisW67
7th June 2015, 21:43
Often you do not want that behaviour. Think about hiding/showing a non-modal toolbox window for example. You could construct it and set it to match the program state every time it is shown (the delete on close case) or construct it once and have it stay in sync with the program state whether hidden or not.

yeye_olive
8th June 2015, 09:31
Besides, the vast majority of widgets are children of other widgets; their lifetime is controlled by their parent, therefore Qt::WA_DeleteOnClose is better left off for them.