If I dynamically create a floating QDockWidget and then call QMainWindow::saveState, the dynamically created QDockWidget's details are not saved. However, if I dock the QDockWidget to the QMainWindow and then call QMainWindow::saveState, the QDockWidget's details are saved. The details are also saved if I float the QDockWidget again. Seems that actually docking the QDockWidget to the QMainWindow has some effect on the operation of QMainWindow::saveState.
Has anyone come across this before?
Here is a code snippet from qmainwindowlayout.cpp:
void QMainWindowLayoutState
::saveState(QDataStream &stream
) const {
#ifndef QT_NO_DOCKWIDGET
dockAreaLayout.saveState(stream);
#endif
#ifndef QT_NO_TOOLBAR
toolBarAreaLayout.saveState(stream);
#endif
}
void QMainWindowLayoutState::saveState(QDataStream &stream) const
{
#ifndef QT_NO_DOCKWIDGET
dockAreaLayout.saveState(stream);
#endif
#ifndef QT_NO_TOOLBAR
toolBarAreaLayout.saveState(stream);
#endif
}
To copy to clipboard, switch view to plain text mode
This is called as part of QMainWindow::saveState. the dynamically created QDockWidget is considered as belonging to one of the four dock areas until it has actually been docked in one of them.
Bookmarks