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:
class MyMainWindow(QMainWindow):
def __init__(self, etc.):
# create a few QDockWidgets
self.hud = HudDockWidget(self)
# snip
self.preferences = Preferences(self)
def closeEvent(self, event):
self.preferences.save()
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:
self.__main_window.resize(self.value('MainWindow/Size',
QVariant(
QSize(800, 600))).toSize())
self.__main_window.restoreState(self.value('State').toByteArray())
def save(self):
self.setValue('MainWindow/Size',
QVariant(self.__main_window.size()))
self.setValue('State', QVariant(self.__main_window.saveState()))
self.sync()
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 <[email protected]> wrote:
>
> The usual "please provide a minimum self containing example" applies.
>
> Pete
> _______________________________________________
> PyQt mailing list [email protected]
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt