Can I save/restore the current state (pos/size...) of a QDockWidget?
-
Hi, I would like to save/restore the position, size and docking-window-state of a group of QDockWidgets in a QApplication.
The state of these QDockWidgets must not be saved in the global QSettings of the application, they must be saved in other project document (It is a XML-user document).
I see the methods to use for all windows of the application:
- void QApplication::saveState(QSessionManager & manager)
- void QApplication::restoreState(QSessionManager & manager)
But I dont know how to save or read the docking-window-state of each QDockWidget instance.
How do I do it?Thanks in advance
-
Hi and welcome to devnet,
That's not the role of these two method.
You have:
- QMainWindow::saveState
- QMainWindow::restoreState
- QMainWindow::saveGeometry
- QMainWindow::restoreGeometry
As for the QDockWidget, each must have a unique object name. It's all explained in the documentation of these methods.
-
@ahuarte said:
I dont want to save in the application QSettings file, but in a xml-node of another file
You can do whatever you want with the returned QByteArray.
and only a group of QDockWidgets.
this is not possible.
-
For the group handling, you can try to restore the state of the QMainWindow before you create the QDockWidgets and then use restoreDockWidget on your group of interest.
-
Also be aware of QTBUG-16252.