I realize this sounds horribly redundant, since pickle and QSettings basically achieve the same thing, but let me explain.
I have a program made up of widgets that can be docked, resized, or otherwise modified. The user wants to be able to save various states as layouts and change between these layouts. The layout is saved as a QSettings file.
To save a list of layouts, I want to pickle a dictionary of the format {'layoutName':qSettingsFile, 'anotherName':anotherFile}, but when I try to pickle a QSettings file I get TypeError: the sip.wrapper type cannot be instantiated or sub-classed.
Is there a way to make this work? I could just put the contents of the QSettings file in the dictionary and forget about QSettings, but I’m hoping for an easier/shorter way.
Use one settings file, and create separate groups for each layout.
The QSettings syntax supports hierarchical keys, so just use beginGroup and endGroup to create named layout sections:
Which would output a file looking like this:
Alternatively, you could use QSettings arrays to create an of indexed list of layouts.