Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What is the format of the data saved by QMainWindow::saveState()?

What is the format of the data saved by QMainWindow::saveState()?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mayaknife
    wrote on last edited by
    #1

    I have a bug in my app which comes down to two different window state files: one works while the other causes my app to crash. I'd like to be able to dump the contents of the two state files in human readable form so that I can compare them to see what's different. What is the format of the data saved by QMainWindowState()?

    Thanks.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      BreakBad
      wrote on last edited by
      #2

      Doesn't it use "QSettings":http://qt-project.org/doc/qt-4.8/qsettings.html#details ? So it would depend on platform

      Also may be worth mentioning: I just read you need to setObjectName for each toolbar and dockwidget for saveState to work (Qt 5). Perhaps you're not doing that in one of your instances?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mayaknife
        wrote on last edited by
        #3

        My object names are fine.

        saveState() returns a QByteArray. I tried casting the result of its data() method to QSettings but that didn't work. So now I'm picking my way through a binary dumpt of the data, trying to figure out its structure.

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          Hi,

          It's a custom binary format. You can examine the source code here to see how the byte stream is constructed: http://code.woboq.org/qt5/qtbase/src/widgets/widgets/qmainwindow.cpp.html#_ZNK11QMainWindow9saveStateEi

          The code browser is interactive. Click on the functions to jump to their definitions. (You will eventually find QToolBarAreaLayout::saveState() and QDockAreaLayout::saveState() which do the writing. These are internal classes, so they are undocumented)

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved