can't close the Qdialog
Solved
The Lounge
-
hi, everyone.
I have a class A which is a QDialog. in its constructor, it must read something from a file and if the file is not opened, the QDialog must be closed. I usedthis->close();
but it doesn't work. what should I do???
thank you very much -
In the constructor the dialog is not even shown yet, so there's nothing to close.
Usually with dialogs you have a code like this:
SomeDialog dialog; dialog.exec(); //exec calls show() internally
so if you want to prevent it from showing you can do something like this:
SomeDialog dialog; if (dialog.isInitialized()) dialog.exec();
where
isInitialized()
would return true or false depending on what the constructor did.