Qt Code:
  1. ...
  2. form_login l;
  3. if (l.exec() == QDialog::Accepted)
  4. {
  5. tmain_form main_form;
  6. main_form.show();
  7. return a.exec();
  8. }
  9. ...
To copy to clipboard, switch view to plain text mode 

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.

Qt Code:
  1. tcontrol *control = new tcontrol();
  2.  
  3. if (control->login())
  4. {
  5. tmain_form main_form;
  6. main_form.show();
  7. return a.exec();
  8. }
To copy to clipboard, switch view to plain text mode 

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.