PDA

View Full Version : QDockWidget not restored with restoreState/saveState



pl01
2nd May 2013, 15:06
Hi,

I use QT 5.0.2 and have a main window that contains several QDockWidgets.
Once the application close, I call



settings.setValue("windowState", saveState());
settings.setValue("geometry", geometry());


And once I open it I call :



restoreState(settings.value("windowState").toByteArray());
restoreGeometry(settings.value("geometry").toByteArray());


But my dock widgets "size" is not correctly restored !

So, does someone has an idea of the problem ? and how to solve it ?

Thanks

BTW : I have take a look on google for a work around... and play with several "possible solution", but no way :-(

Santosh Reddy
3rd May 2013, 17:00
I think your problem is with multiple QDockWidgets, from your example it is evedent that it will not work as all the QDockWidget save and restore the settings with same key value, you will need to differentiate them, somting like


settings.setValue("windowState1", windowState1.saveState());
settings.setValue("geometry1", geometry1.geometry());

settings.setValue("windowState2", windowState2.saveState());
settings.setValue("geometry2", geometry2.geometry());

settings.setValue("windowState3", windowState3.saveState());
settings.setValue("geometry3", geometry3.geometry());


or use QSetting arrays.