Show mainwindow from another window

Hello
I want to show the main window from another window.
For instance
i have a login form and i managed to open another window from the login form using

this->hide();
emp=new employeeinfo();
emp->show();

Now i have a pushbutton on the employeeinfo ui and i want to go back to the main login window when i press the push button.
i don't know what to include.
i tried to include "mainwindow.h" and then declare mainwindow *main; in private
However , it says 'MainWindow' does not name a type.

Once your problem is solved please do:
Use the Topic Tools button to mark as Solved and
Upvote the answer(s) that helped you to solve the issuepostimage.org can be used for screenshots.
Get on the inside track at https://www.qtworldsummit.com/

Hello thank you , this worked :)
However, i have a question regarding this.
Is this the right way to toggle between windows.
I mean we hide the window using this->hide(); , so the window is still using the memory , its just hidden. If i make a program with a lot of windows , all of them will just be hidden and not closed.
So is this the right way , or is there a different way to load another window from mainwindow.
Thank you :)

Hi
well, normally a program have a mainwindow and pop dialogs over it.
So mainwin is always shown and the dialogs are created/shown/deleted

There is nothing wrong in hiding the window but it really depends on what you want.

You can create a new window each time, but then you are not going back to it, you
just show a new version.
in any place in the program , you could

MainWindow *newmain= new MainWindow()
newmain->show()

and have a brand new mainwindow

but its not so common to do with mainwindow, its more for dialogs or
other type of windows.

your design do sound like the normal one where u pop a dialog over mainwindow.
except you want to hide mainwindow.

So its not complete crazy :)

Once your problem is solved please do:
Use the Topic Tools button to mark as Solved and
Upvote the answer(s) that helped you to solve the issuepostimage.org can be used for screenshots.
Get on the inside track at https://www.qtworldsummit.com/

Ok so if i want to open a profile page after the login page , a dialog should do?
I tried using dialog , however it does not have the maximize and minimize buttons , that is why is decided to use main window.
What do you suggest?

it would first show login (blocking mainwin)
if user press ok, then show profile. still blocking mainwind

etc.

Once your problem is solved please do:
Use the Topic Tools button to mark as Solved and
Upvote the answer(s) that helped you to solve the issuepostimage.org can be used for screenshots.
Get on the inside track at https://www.qtworldsummit.com/