How do I distroy an object when clicking on the x?
Hi Gurus,
I have a gui which calls another gui like so:
Code:
if (userManager==0)
{
userManager = new UserManager();
}
userManager->show();
This then launches the user manager window. So now how do I make sure that the ~UserManager gets executed when someone closes the window by clicking on the x?
I know I should delete the reference to UserManager, but where do I do this?
Thanks a million
RT
Re: How do I distroy an object when clicking on the x?
You can use:
Code:
userManager->setAttribute(Qt::WA_DeleteOnClose, true);
It will be deleted by QObject::deleteLater()
Re: How do I distroy an object when clicking on the x?
Additionally, to make sure your Pointer is set to null after the window is closed, you could either use http://doc.trolltech.com/4.7/qobject.html#destroyed or a QPointer