Layout restore does not work properly



  • 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:

    Save:
    @
    QSettings trdset;
    trdset.begingGroup("aGroup")
    ... here is saved our data
    trdset.endGroup();
    trdset.beginGroup("General");
    trdset.setValue("STATE", saveState());
    trdset.setValue("GEOMETRY",saveGeometry());
    trdset.ednGroup()
    @
    Restore:
    @
    QSettings trdset;
    trdset.beginGroup("General");
    QByteArray layout_data = trdset.value("STATE").toByteArray();
    QByteArray geometry_data = trdset.value("GEOMETRY").toByteArray();
    trdset.endGroup();//General

    restoreGeometry(geometry_data);
    trdset.begingGroup("aGroup")
    ... here is read our data
    trdset.endGroup();
    ... here QDockWidgets are created
    restoreState(layout_data);
    @
    When loading run-time, first we call a method that close the docks(and just after the loading from ini file):
    @
    void LayoutWindow::closeAllReps()
    {
    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...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.