I have a main window with some internal dockable windows. I can move, resize and redock those dockable windows. After close and reopen the program, I want the moves, sizes and redocking are kept. Any easy way to implement it? I think it will use settings. But which info should be saved in settings. And how to set a default layout of all these dock windows? When click an action button, it can be restored. Thanks.
Check out QMainWindow::saveState/restoreState. It does exactly this.
To Save:
QSettings settings;
settings.setValue("DOCK_LOCATIONS",this->saveState(SOME_VERSION_DEFINE));
To Restore:
QSettings settings;
this->restoreState(settings.value("DOCK_LOCATIONS").toByteArray(),SOME_VERSION_DEFINE);
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