I now have the main program working mostly as axeljaeger has suggested, with an additional connection to make the program quit after the last window is closed:

Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. QApplication app(argc, argv);
  4. ALoginView loginView;
  5. AMainView mainView;
  6. loginView.show();
  7. app.connect(&loginView, SIGNAL(accepted()), &mainView, SLOT(show()));
  8. app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
  9. return app.exec();
  10. }
To copy to clipboard, switch view to plain text mode 

It works as expected as long as the login dialog is closed by clicking on the login button. However if I hit the enter key in a textedit instead, the main window is displayed very short, but then the program immediately terminates.

Any ideas what could be the reason? Do I need to quit the program in a different way, or is quitting not necessary at all (such as in axeljaeger's example)?