Answer the question
In order to leave comments, you need to log in
How to show authorization window in c++ before main window?
It is necessary to show the authorization window before the main window. And if you click "Cancel" in the window or enter the wrong password, the application ends.
How I did it: I created an application class and a class for authorization. In the wxPanel authorization class constructor *panel = new wxPanel(this, wxID_ANY);
wxButton *button = new wxButton(panel, wxID_EXIT, wxT("Quit"),
wxPoint(20, 20));
wxButton *buttonOk = new wxButton(panel, wxID_OK, wxT("Ok"), wxPoint(20,50));
Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(AuthFrame::OnOk));
Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(AuthFrame::OnQuit));
From the application class, I create an instance of the AuthFrame authorization class. As a result, the main application window and the authorization window appear. How can I make it so that only the authorization window is shown and the result is passed to the main application class?
All this is done on ubuntu 12.04 using c++ and wxWidgets.
Answer the question
In order to leave comments, you need to log in
Here is the Qt code that does what you need:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
AuthFrame askPassword;
if (askPassword.exec() == QDialog::Rejected)
{
return 0;
}
MainWindow w;
app.exec();
}
if (askPassword.exec() == QDialog::Rejected)
{
return 0;
}
int result = askPassword.result();
MainWindow w(result);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question