Momergil
13th October 2013, 04:46
Hello!
My question: is there a difference between using setAttribute(Qt::WA_DeleteOnClose, true); and deleteLater(); ?
To give a context: I want to create a modeless dialog, so I may use it and its parent at the same time. But I also don want just to create a pointer to it using show() and no delete ... to avoid unecessary memory comsumption when the dialog is closed and its parent isn't yet closed. So I figured out that, if I put deleteLater() in the closeEvent(QClosEvent*); reimplemented function or if I use the window attribute, setting it in the constructor, either way the object is destroyed when the dialog is closed.
A second question is, which of them should I use preferentially?
Thanks,
Momergil
My question: is there a difference between using setAttribute(Qt::WA_DeleteOnClose, true); and deleteLater(); ?
To give a context: I want to create a modeless dialog, so I may use it and its parent at the same time. But I also don want just to create a pointer to it using show() and no delete ... to avoid unecessary memory comsumption when the dialog is closed and its parent isn't yet closed. So I figured out that, if I put deleteLater() in the closeEvent(QClosEvent*); reimplemented function or if I use the window attribute, setting it in the constructor, either way the object is destroyed when the dialog is closed.
A second question is, which of them should I use preferentially?
Thanks,
Momergil