First when the application start I display the login screen. Then after successful login i have to display the main window. What is the right way to close the login screen and display the main window?

At the moment i have something like this:
Qt Code:
  1. main_window *main = new main_window();
  2. this->close(); // close login
  3. main->show(); // show main
To copy to clipboard, switch view to plain text mode 

When i call main_window *main = new main_window(this), then the application is not working right.

I have searched Qt examples & demos but all use just one window.