How to open MainWindow from Dialog

  • #include "options.h"
    #include "ui_options.h"
    #include "mainwindow.h"
    Options::Options(QWidget *parent) :
        ui(new Ui::Options)
        delete ui;
    void Options::on_pushButton_2_clicked()
        MainWindow w;;

    This executes without errors but does nothing, im trying to reopen the main window from a dialog window

  • Moderators

    MainWindow w;
    This constructs an entirely new MainWindow, puts it on the stack. Then 2 lines later the scope ends } and your main window is destroyed.

    You should rather pass a pointer to your actual MainWindow instance when creating the dialog, and then show it when pushButton2 is clicked.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.