How to avoid displaying QMainWindow
-
Hi All
I have created QApplication project.
In the constructor I am doing some condition checking and on failure
that condition i am poping up error message with OK button .
so when the user clicks OK button my MainWindow should not open.
How to do this? -
I don't see what's the problem in putting that inside a if statement. Can you elaborate or your problem is really that simple?
-
It is not clear what "should not open" means. If you don't want to start (i.e., load and initialize) the mainwindow then you have to do your check before the window is created (i.e., in the main) and then do a simple if statement. If you mean that the window should be not visible, than in the constructor you can call setVisible with the result of your condition.
-
It is trivial:
@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);// check the condition here if(checkMyStuff()) { MainWindow w; w.show(); return a.exec(); } return 0;
}
@