my application requires the user to switch between several screens. The way I'm doing this is by creating different QFrames for each screen, and then setting the Qframes as central widgets on the MainWindow. The problem is that every time I call setCentralWidget(frame), the old frame gets deleted and I can't access it later. How can save that old frame so that I can access it later?
Please let me know if I am unclear in my question.
You can remove your central widget from QMainWidow
reparenting it. Then, you could set new centralWidget;
QWidget* savedWidget = mainWnd->centralWidget();
savedWidget->setParent(0);//now it is saved
mainWnd->setCentralWidget(newWidget);
Also using QStackedWidget
possibly would be better solution.
QStackedWidget is an elegant solution for this problem, you can find out how to use it properly here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With