[Solved] QDialog shuts down the whole application
-
Good day, colleagues!
I want to write the authentication dialog before the main window start. So, I have this code:
@QApplication app (argc, argv);
Preferences_Getter getter (PREFERENCES_URL);
Main_Window window;QObject::connect(&getter, SIGNAL (Finished(const QByteArray &)), &window, SLOT(show()));
return app.exec();@
Preferences_Getter is QObject with QNetworkAccessManager. Authenntication code is:
@void Preferences_Getter::Authenticate (QNetworkReply * reply, QAuthenticator * authenticator) {
QDialog dlg;
...
if (dlg.exec() == QDialog::Accepted) {
authenticator->setUser(ui.userEdit->text());
authenticator->setPassword(ui.passwordEdit->text());
}
...
}@When I accept QDialog, my whole application shuts down. When I reject QDialog, main window starts normally.
How can I fix it?
-
The point is the following:
Afaik, the signal QApplication::lastWindowClosed is connected to QApplication::quit.
As you have no other window than the dialog visible, it's the last window to close...When do you call Authenticate? inside the app.exec() I think?