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, the dock widgets states do not work:<br>
<br>class MyMainWindow(QMainWindow):<br><br> def __init__(self, etc.):<br> # create a few QDockWidgets<br> self.hud = HudDockWidget(self)<br> # snip<br> self.preferences = Preferences(self)<br>
<br> def closeEvent(self, event):<br> self.preferences.save()<br><br><br>class Preferences(QSettings):<br><br> def __init__(self, mainwindow=None):<br> QSettings.__init__(self, mainwindow)<br><br> self.__main_window = mainwindow<br>
<br> # Load some things on startup<br> if self.__main_window is not None:<br> self.__main_window.resize(self.value('MainWindow/Size', QVariant(<br> QSize(800, 600))).toSize())<br>
self.__main_window.restoreState(self.value('State').toByteArray())<br><br> def save(self):<br> self.setValue('MainWindow/Size', QVariant(self.__main_window.size()))<br> self.setValue('State', QVariant(self.__main_window.saveState()))<br>
self.sync()<br><br><br>class HudDockWidget(QDockWidget):<br> "Dock widget which contains all of the HUD widgets"<br> def __init__(self, parent=None):<br> QDockWidget.__init__(self, 'Heads up Display', parent)<br>
<br><br><div class="gmail_quote">On Wed, Nov 11, 2009 at 4:04 PM, Hans-Peter Jansen <span dir="ltr"><<a href="mailto:hpj@urpla.net">hpj@urpla.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div class="h5">
<br>
</div></div>The usual "please provide a minimum self containing example" applies.<br>
<br>
Pete<br>
<div><div></div><div class="h5">_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</div></div></blockquote></div><br>