PDA

View Full Version : Multiple Windows -> Advice needed



vokal
8th January 2007, 08:12
hy

i need an advice....
i would like to develop an application with multiple windows, and I don't know where to start from.
I took a look at the "toplevel" example, but I understood that it doesn't really create a new window ( IT IS A HIGH PROBABILITY THAT I AM WRONG... :) ).
anyway... what I would like to do, is to have a server/ client application, in witch the client must have 2 windows

one must contain informations, and the other is the Login Window.
the login window must be showed first, while the main window must be hidden.
after getting the positive response from the server, the login window must close, and the main window with informations must show up.

thank you for your time, and help..:)

munna
8th January 2007, 08:39
When the client loads the application, then you will first need to show the login window and then when the client is authenticated, you can close the login window and show the main window.

1. Have a class called LoginDlg which will need to reimplement QDialog. This dialog will have couple of input boxes (For username, password etc) and couple of buttons (ok, cancel).

2. connect the pressed singal of ok button to a slot in this class.

3. When ok is pressed, this slot can then send the information to the server for authentication.

4. Once you get a positive response, create the main window and close the login dialog.

If you look into the file options.ui.h, it has the slot called apply(), which is called when the "apply" button is clicked. In that slot, a new widget is created, which pops up when the "apply" button is pressed. Your case is also something similar

wysota
8th January 2007, 08:40
Something like this should be ok:

int main(int argc, char **argv){
QApplication(argc, argv);
LoginDialog dlg;
if(!dlg.exec() || !dlg.loginOk()){
qDebug("Login failed");
return 1;
}
MainWindow mw;
//...
return app.exec();
}