What I like to do is first show a dialog where the user can login to the database. On successfull connect/login this dialog shall be closed and a main window for the application shall be displayed. On error the login window shall stay open for retry, and by cancel button the application shoud terminate.

Does anybody have or know about a sample how this is properly done, or at least give a snippet of the main() function demonstrating the chaining?