c++ - What is the best way to communicate between two windows in Qt -


what best way communicate between 2 windows in qt?

i need have separate login window , main application window appears 1 after (the second one, mean main application window, show if login successful). should create these 2 objects (login window , main application objects) in main function or make login window data member of main application class , create in constructor of main application class?

you can create login window data member of main application class , create in constructor. next can invoke login connecting signal named login_ asked() of main class slot named perform_login() , emitting signal after that:

qobject::connect(this,signal(login_asked()),this,slot(perform_login())                                                 ,qt::queuedconnection); emit login_asked(); 

you should hide main window in perform_login() slot , show login form like:

this->setvisible(false);  loginfm->show(); 

you can notify main application of failure or success in login signals , slots like:

qobject::connect(loginfm,signal(login_accepted()),this,slot(entered())); qobject::connect(loginfm,signal(login_canceled()),this,slot(canceled())); 

in the slot entered() of main window should show main window:

this->setvisible(true); 

this way can invoke login many during application life cycle emiting login_asked() signal.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -