PDA

View Full Version : Quitting before the QApplication::exec()



jsmax
17th April 2008, 19:18
Hi all.

I have an application that works with databases. Before it starts executing it shows a dialog that asks for the connection parameters (user, password). I'd like to make that when a user presses the Cancel button, the application must quit.

For example:



//-------------------------//
int ret = ConnDialog.exec();
if (ret == QDialog::Rejected)
app.quit();
//-------------------------//
app.exec(); // Here starts the main loop
//-------------------------//


But it doesn't work. The QApplication::quit() works only inside the main loop.
How can i quit the application before the main loop ? Thnx ...

wysota
17th April 2008, 19:44
Simply return from main().


int main(...){
//...
if(ret == QDialog::Rejected)
return 1;
return app.exec();
}

jsmax
17th April 2008, 20:19
Oh ! Shame to me ! My mind is giving up after 2 days of hard work on this app ....

Thnx a lot !