Important: Please read the Qt Code of Conduct -

Nested QToolBar state restore not working

  • Hi,

    I have an application based on QMainWindow which has toolbars in it that the user can dock as they please.

    I want to save and restore this state (along with some QDockWidgets) when the programme exits/starts.

    Most of this I have working OK using the saveState/restoreState functions, but with one major problem.

    If the user has more than one row of toolbars the restoreState function puts all the toolbars back in a single row, not in the multiple rows I started with and there doesn't appear to be any way of programmatically creating more than one row to fix it after the event.

    Any ideas how I can get this working (short of throwing away all the QMainWindow functionality and writing my own)?


  • Lifetime Qt Champion


    Did you give all your toolbars object names ?

  • I thought I was, I'm allocating UUIDs for the names and then reasserting them when I recreate the toolbars.

    I took a closer look after your response, turns out I had forgotten two that aren't optional for the user and it was these two stopping the others from correct placement.

    Thanks very much, problem solved.

  • Lifetime Qt Champion

    Glad you found !

    Since you have it working now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)

Log in to reply