PDA

View Full Version : QDialog problem with exec()



nomadscarecrow
23rd April 2010, 18:13
...
form_login l;
if (l.exec() == QDialog::Accepted)
{
tmain_form main_form;
main_form.show();
return a.exec();
}
...


Hi I'm using this code to show a login form on the main.cpp file.

When used in this way before the a.exec(), everything works fine.
But when I try this, the exec() is not executed in the usual way, the dialog is closed not waiting for user action.



tcontrol *control = new tcontrol();

if (control->login())
{
tmain_form main_form;
main_form.show();
return a.exec();
}


and login is just a method wrapping the first code, returning (l.exec() == QDialog::Accepted)

What is the difference?

I'm missing something?

Thanks in advance.

wysota
23rd April 2010, 18:20
Disconnect the lastWindowClosed() signal in the application object from its quit() slot.

nomadscarecrow
23rd April 2010, 18:34
Disconnect the lastWindowClosed() signal in the application object from its quit() slot.

Thanks for the reply.

Before the tcontrol *control = new tcontrol(); line, I use this a.setQuitOnLastWindowClosed(false); as I check on documentation:


void QApplication::lastWindowClosed () [signal]
...
This feature can be turned off by setting quitOnLastWindowClosed to false.

but the result is the same.

wysota
23rd April 2010, 18:40
Please provide a minimal compilable example reproducing the problem.