I have a dialog window with a class of QDialog. I declare it in the header files with:
MyDialogClass myDialogWindow = nullptr;
and create the window on runtime somewhere with
myDialogWindow = new MyDialogClass(this);
It is also delf destroying, because of it's attributes:
this->setAttribute(Qt::WA_DeleteOnClose);
Does anyone now how can I set the myDialogWindow pointer to nullptr after the self deletion without connection signals?
Thanks in advance.
This isn't possible without some signal or event logic. The object does not own the pointer, the pointer is pointing at the object.
However you can use a QPointer which wraps the signal handling and nulling for you.
QPointer<MyDialogClass> myDialogWindow;
myDialogWindow = new MyDialogClass(this);
myDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
// some time later, check dialog has not been closed
if( ! myDialogWindow.isNull() )
{
// do something with dialog
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With