Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Layout restore does not work properly
lbarsan last edited by
We have a complex GUI based app, mainly consisting of QMainWindow, which includes many QDockWidget based window. Each customer has several layouts saved in correspondent .ini files via QSettings.
The saving and restoring works well when application started, the layout is restored perfectly.
But our customers wants to change the layout run-time, when the application is up, they want another layout loaded and this does not work properly, apparently the QDockWidgets are restored chaotically, on other position then set in layout. I mention that same layout is restored well if loaded at startup !
The code is long, so I describe here the main steps how we handle the layout save/restore:
... here is saved our data
QByteArray layout_data = trdset.value("STATE").toByteArray();
QByteArray geometry_data = trdset.value("GEOMETRY").toByteArray();
... here is read our data
... here QDockWidgets are created
When loading run-time, first we call a method that close the docks(and just after the loading from ini file):
QList<QDockWidget *> dockWidgets = findChildren<QDockWidget *>();
QList<QDockWidget >::iterator itL = dockWidgets.begin();
for(;itL != dockWidgets.end();itL++)
QDockWidget dw = (*itL);
bool isReallyClosed = dw->close();// is also deleted since DeleteOnClose flag is set
assert(isReallyClosed == true);
Any idea welcome...