PDA

View Full Version : How to close QMainWindow and open login dialog



keeyias
7th August 2009, 15:21
The problem goes like this,
In an application I am building, I have one instance of LoginDialog inherited from QDialog. This takes username and password, if match is not found in the mysql database, the loginvalidate() returns 0. Return type of loginValidate of LoginDialog is used to determine whether or not to exit the program from the event loop in the main function. If match is found, program flow is as usual, opens the main window.

Now here comes the problem. I have logout button in the QMainWindow inherited class. When it is clicked, private slot, logout() is called, in the logout() slot, i can write close() to close the current instance of QMainWindow, but how can I show to login dialog, Well, making a new object newlogin will help but still, slots in the LoginDialog won't call QMainWindow. What can I do.

THank you in advance.

Keeyias

pedromorgan
5th October 2009, 15:31
I have Exactly the same problem.

scascio
5th October 2009, 16:22
What are you doing if the first logging fails? Do you offer to log in again?
It is quite the same problem, isn't it?

Are you doing a loop in the main?

Tanuki-no Torigava
15th October 2009, 12:33
Hi guys, I suggest you to try 2 different approaches:

1. Just hide/unhide main window;
2. De/Initialize eveything inside qapplication event loop.

Another good techniques include move of the login dialog and main window into 2 different threads.