Results 1 to 4 of 4

Thread: QDockWidget saveState and restoreState

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDockWidget saveState and restoreState

    I'm having a similar problem at the moment where some of the states of QDockWidgets are not restored (like floatable). I'm looking into this at the moment and will hopefully find a solution.

  2. #2
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDockWidget saveState and restoreState

    I've managed to narrow down the strange behaviour to nested dock widgets.

    • Call QMainWindow::saveState on a main window with two docked QDockWidgets which are nested/tabbed
    • Float one of the nested/tabbed QDockWidgets
    • Call QMainWindow::restoreState


    EXPECT: Both QDockWidgets to be nested/tabbed as they were before QMainWindow::saveState.
    ACTUAL: The docked, nested/tabbed state of the QDockWidget is not restored - it's left floating.

    I have not had time to create example code to demonstrate this. Would it be of use to anyone?

  3. #3
    Join Date
    Oct 2015
    Posts
    3

    Default Re: QDockWidget saveState and restoreState

    The same problem :/

    In general I have a big problem with restoreState/restoreGeometry, QSettings ini file looks good after saving (objectname (is unique), dockwidget area, geometry),
    Qt Code:
    1. [docks]
    2. dock\1\objectName="Type_1;5"
    3. dock\1\area=2
    4. dock\1\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\x4\xc8\0\0\x1\x45\0\0\x6\x31\0\0\x2H\0\0\x4\xc8\0\0\x1\x45\0\0\x6\x31\0\0\x2H\0\0\0\0\0\0\0\0\a\x80)
    5. dock\2\objectName="Type_2;3"
    6. dock\2\area=2
    7. dock\2\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\x4\xc8\0\0\0\x1e\0\0\x6\x31\0\0\x1\x42\0\0\x4\xc8\0\0\0\x1e\0\0\x6\x31\0\0\x1\x42\0\0\0\0\0\0\0\0\a\x80)
    8. dock\3\objectName="Type_3;4"
    9. dock\3\area=8
    10. dock\3\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\x2\xbc\0\0\x6\x31\0\0\x3s\0\0\0\0\0\0\x2\xbc\0\0\x6\x31\0\0\x3s\0\0\0\0\0\0\0\0\a\x80)
    11. dock\4\objectName="Type_4;7"
    12. dock\4\area=2
    13. dock\4\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\x4\xc8\0\0\x2K\0\0\x6\x31\0\0\x2\xb9\0\0\x4\xc8\0\0\x2K\0\0\x6\x31\0\0\x2\xb9\0\0\0\0\0\0\0\0\a\x80)
    14. dock\5\objectName="Type_5;2"
    15. dock\5\area=1
    16. dock\5\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\0\x1e\0\0\x1O\0\0\x1\xb1\0\0\0\0\0\0\0\x1e\0\0\x1O\0\0\x1\xb1\0\0\0\0\0\0\0\0\a\x80)
    17. dock\6\objectName="Type_6;5"
    18. dock\6\area=1
    19. dock\6\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\x1\xb4\0\0\x1O\0\0\x2\xb9\0\0\0\0\0\0\x1\xb4\0\0\x1O\0\0\x2\xb9\0\0\0\0\0\0\0\0\a\x80)
    20. dock\7\objectName="Type_7;3"
    21. dock\7\area=0
    22. dock\7\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\f\x84\0\0\x2\x39\0\0\xe(\0\0\x3\x96\0\0\f\x8c\0\0\x2X\0\0\xe \0\0\x3\x8e\0\0\0\x1\0\0\0\0\a\x80)
    23. dock\size=7
    24.  
    25. [Window]
    26. geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\x80\0\0\0\x33\0\0\x6\xc1\0\0\x3\xe1\0\0\0\x88\0\0\0R\0\0\x6\xb9\0\0\x3\xd9\0\0\0\0\0\0\0\0\a\x80)
    27. windowState="@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x3\0\0\0\0\0\0\x1P\0\0\x2\x9c\xfc\x2\0\0\0\x2\xfb\0\0\0\x1a\0T\0\x65\0l\0\x65\0m\0\x65\0t\0r\0y\0_\0\x35\0;\0\x32\x1\0\0\0\x1e\0\0\x1\x94\0\0\x1!\0\xff\xff\xff\xfb\0\0\0\x18\0M\0\x61\0i\0n\0V\0i\0\x65\0w\0_\0\x36\0;\0\x35\x1\0\0\x1\xb4\0\0\x1\x6\0\0\x1\x4\0\xff\xff\xff\0\0\0\x1\0\0\x1j\0\0\x2\x9c\xfc\x2\0\0\0\x3\xfb\0\0\0*\0\x41\0r\0t\0i\0\x66\0i\0\x63\0i\0\x61\0l\0H\0o\0r\0i\0z\0o\0n\0_\0\x32\0;\0\x33\x1\0\0\0\x1e\0\0\x1%\0\0\0\xc8\0\xff\xff\xff\xfb\0\0\0\x18\0M\0\x61\0i\0n\0V\0i\0\x65\0w\0_\0\x31\0;\0\x35\x1\0\0\x1\x45\0\0\x1\x4\0\0\x1\x4\0\xff\xff\xff\xfb\0\0\0\x1a\0L\0o\0g\0P\0l\0\x61\0y\0\x65\0r\0_\0\x34\0;\0\x37\x1\0\0\x2K\0\0\0o\0\0\0o\0\xff\xff\xff\0\0\0\x3\0\0\x6\x32\0\0\0\xb8\xfc\x1\0\0\0\x1\xfb\0\0\0&\0W\0\x61\0y\0P\0o\0i\0n\0t\0s\0W\0i\0\x64\0g\0\x65\0t\0_\0\x33\0;\0\x34\x1\0\0\0\0\0\0\x6\x32\0\0\x3O\0\xff\xff\xff\0\0\x3t\0\0\x2\x9c\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\0)"
    28. size=@Size(1586 904)
    29. pos=@Point(128 51)
    To copy to clipboard, switch view to plain text mode 
    but after loading it looks bad:| (especially in case when added before new dockwidgets, and removed some of old) :/
    this is how i load it
    Qt Code:
    1. QSettings settings(QApplication::applicationDirPath() + fileini, QSettings::IniFormat);
    2.  
    3. settings.beginGroup("docks");
    4.  
    5. int DocksCount = settings.beginReadArray("dock");
    6. if(DocksCount > 0)
    7. {
    8. for(int i = 0; i < DocksCount; i++)
    9. {
    10. settings.setArrayIndex(i);
    11.  
    12. QString objectName = settings.value("objectName").toString();
    13.  
    14. QDockWidget* dock = addSubWindow(objectName);
    15. if(dock)
    16. {
    17. Qt::DockWidgetArea area = static_cast<Qt::DockWidgetArea>(settings.value("area").toInt());
    18. this->addDockWidget(area, dock);
    19. dock->restoreGeometry(settings.value("geometry").toByteArray());
    20. }
    21. }
    22. }
    23. settings.endArray();
    24. settings.endGroup();
    25.  
    26. settings.beginGroup("Window");
    27. restoreGeometry(settings.value("geometry").toByteArray());
    28. restoreState(settings.value("windowState").toByteArray());
    29.  
    30. resize(settings.value("size", QSize(1200, 800)).toSize());
    31. move(settings.value("pos", QPoint(0, 0)).toPoint());
    To copy to clipboard, switch view to plain text mode 

    any help?

    Regards,
    DizL
    Last edited by DizL; 28th January 2016 at 10:04.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.