Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any easy way to store dock widows layout and sizes in settings with Qt?

Tags:

qt

docking

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.

like image 335
user1899020 Avatar asked Jan 12 '13 00:01

user1899020


1 Answers

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);
like image 121
Michael Avatar answered Oct 02 '22 09:10

Michael