Important: Please read the Qt Code of Conduct -

How to launch mainwindow from a dialog window?

  • Ok, so the program starts out with a dialog window requesting information from the user to log on. How can I get the mainWindow to open from the dialog window. Thanks.

  • Off the top of my head, I would implement it like this.

    QApplication a(argc,argv);
    MyMainWindow b;
    return a.exec();

    Note the missing; command.

    Then, in the constructor for MyMainWindow,

    MyOpenDialog *a = new MyOpenDialog();

    As long as MyOpenDialog is set as Application Modal, you won't process the until after the dialog has closed.

    Edit: I should add, if you're all done with MyOpenDialog, you'll want to
    @delete a;@ afterwards;

  • Dear Keozon,

    Would you mind to show in complete file MyMainWindow.cpp?
    Thanks in advance.

  • bq. MyOpenDialog *a = new MyOpenDialog();

    i think the a->exec() should be followed by some check-up functions that call the .show() if log in was successful.

    go for it !

Log in to reply