[PyQt] restoreState not working for QDockWidgets
phil at riverbankcomputing.com
Thu Nov 12 10:00:20 GMT 2009
This is not a self contained example, ie. one that we can run. How do you
know that these are the "relevant pieces"? By presenting us with a fragment
of code you are making the assumption that it must demonstrate the problem
- even though you have already said you don't know what the problem is.
One possible problem is that you are not giving the dock widget a name (see
the docs for QMainWindow.saveState()), but as your fragment has "# snip"
below the call to create it then who can tell?
On Thu, 12 Nov 2009 00:08:09 -0800, Brian Zambrano <brianz at gmail.com>
> The relevant pieces are basically this...have the main window save state
> when it closes. On startup, the main window passes itself to a QSettings
> wrapper where the state should be restored. The resize works just fine,
> dock widgets states do not work:
> class MyMainWindow(QMainWindow):
> def __init__(self, etc.):
> # create a few QDockWidgets
> self.hud = HudDockWidget(self)
> # snip
> self.preferences = Preferences(self)
> def closeEvent(self, event):
> class Preferences(QSettings):
> def __init__(self, mainwindow=None):
> QSettings.__init__(self, mainwindow)
> self.__main_window = mainwindow
> # Load some things on startup
> if self.__main_window is not None:
> QSize(800, 600))).toSize())
> def save(self):
> self.setValue('State', QVariant(self.__main_window.saveState()))
> class HudDockWidget(QDockWidget):
> "Dock widget which contains all of the HUD widgets"
> def __init__(self, parent=None):
> QDockWidget.__init__(self, 'Heads up Display', parent)
> On Wed, Nov 11, 2009 at 4:04 PM, Hans-Peter Jansen <hpj at urpla.net> wrote:
>> The usual "please provide a minimum self containing example" applies.
>> PyQt mailing list PyQt at riverbankcomputing.com
More information about the PyQt