M.A
M.A

Reputation: 1133

Making a dialog window persisten in QT c++

I have a main window and a dialog window in QT. I want users to login first before proceeding to the main window. Oh yes, the dialog window is my login page. Can advice on how to proceed. I got a button btnSubmit which connects to a slot called getLoginDetails(). How can i make sure the user has login before proceeding to the main window. When i type this, there is no errors but the Login Form is not appearing.

int main (){

QApplication app(argc, argv);

    LoginAccess objLA;
bool status;
status = objLA.getLoginDetails2();
if (status==false){
    LoginForm objL;
    objL.show();
}else{
 mainForm objM;
 objM.show();
}
}

Upvotes: 0

Views: 143

Answers (1)

Martin Beckett
Martin Beckett

Reputation: 96147

You need an application.exec() to start the event loop - even if you are doign a modal dialog first

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

MainWindow win;

LoginAccess objLA;
    if ( ! objLA.getLoginDetails2() ) {
         exit(1);
    }

    win.show();
    return app.exec();  
}

Upvotes: 1

Related Questions