[PyQt] saveState()/restoreState() of a nested QMainWindow

Bram Marien B.Marien at Intersentia.be
Wed Jan 5 15:48:51 GMT 2011


Hello everybody,

I'm trying to use QSettings to save and restore the window configuration, and the size and position of its docking widgets to be more precise, in my application.

My application is a normal QMainWindow (let's call this 'outer'), which has a QDockWidget, and a normal QWidget as its centralWidget.
That centralWidget has a layout, and another QMainWindow as it's only widget (let's call this one 'inner').

That 'inner' QMainWindow also has a dock widget.

When I use QSettings to save and restore the state of the application (so : bother outer as inner QMainWindow), it  does it job perfectly for the 'outer' window : It restores both the location and the size of its docking widget.
But the docking widget of the 'inner' window is not restored correctly : QSettings only recovers its location (Left/Bottom/...) but discards the stored size:  It seems to use the sizeHint rather than the user-preferred size.

Am I doing something wrong with the QSettings usage?
I know the 'QMainWindow in QMainWindow' is rather funky, but I'd really like the dock-concept in the inner central widget.
And also : the inner QMainWindow may one day live on it's own, in stead of being a widget in another window...

Here's some demo-code to show my problem:  http://pastebin.com/07NJJvDm

My configuration : Windows Vista with Python 2.7, Qt 4.7.0 and PyQt 4.8.1

Many thanks in advance,

Bram

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110105/bf9097e7/attachment.html>


More information about the PyQt mailing list