How to open MainWindow from Dialog
Unsolved
General and Desktop
-
#include "options.h" #include "ui_options.h" #include "mainwindow.h" Options::Options(QWidget *parent) : QDialog(parent), ui(new Ui::Options) { ui->setupUi(this); } Options::~Options() { delete ui; } void Options::on_pushButton_2_clicked() { this->close(); MainWindow w; w.show(); }
This executes without errors but does nothing, im trying to reopen the main window from a dialog window
-
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.