You can't call QDialog::exec() and do what you want. From the docs:
A dialog window is a top-level window ...
...
...if it has a parent, its default location is centered on top of the parent's top-level widget ...
Change your slot to this:
void MainWindow::on_btnNextPage_clicked()
{
Page2* page2 = new Page2 () ; // Page2* page2 = new Page2 (this) ; ??
setCentralWidget(page2);
}
void MainWindow::on_btnNextPage_clicked()
{
Page2* page2 = new Page2 () ; // Page2* page2 = new Page2 (this) ; ??
setCentralWidget(page2);
}
To copy to clipboard, switch view to plain text mode
The mainWindow takes ownership of the widget so you don't need a this pointer.
The widget that was previously the central widget will be deleted so you will save on memory but if you should want to reload any previous widget you will have to poll your database again and re-instantiate the widget.
I agree with Lykurg's comment in your other post about QStackedWidget not normally being a resource problem.
HTH
Bookmarks