Skip to content Skip to sidebar Skip to footer

Qt - Pyside - .saveGeom() .saveState() (again)

This is a follow on question to Qt - pyside - saveGeometry() saveState() I have a Qt program and currently I use Qsettings and the mainWindow.saveGeometry() and mainWindow.saveStat

Solution 1:

Ok guys. Here is the answer. There is a bug in Qt. When the main window is maximised and the QdocWidget's are docked (not floating) then the floating position is not saved.

This code is a simple workaround.

to save:

settings = QtCore.QSettings(org_name, app_name)
is_floating = main_win._ui.dockWin.isFloating()
settings.setValue('dockWin/isFloating', is_floating)
main_win._ui.dockWin.setFloating(True)
settings.setValue('geometry', main_win.saveGeometry())
settings.setValue('state', main_win.saveState())

to restore:

settings = QtCore.QSettings(org_name, app_name)
main_win.restoreGeometry(settings.value('geometry'))
main_win.restoreState(settings.value('state'))
main_win._ui.dockWin.setFloating(settings.value('dockWin/isFloating')=='true')

Post a Comment for "Qt - Pyside - .saveGeom() .saveState() (again)"