QSplitter::restoreState() not working
Hey all!
I have a quick question: When using a splitter, I would like it to restore itself to the position it was at last time the application closed. I have been able to restore the main window's geometry just fine, but when attempting to restore a splitter, it doesn't work.
When the application starts:
Code:
// Main window settings
settings.beginGroup("mainWindow");
restoreGeometry(settings.value("geometry").toByteArray());
splitter->restoreState(settings.value("splitterState").toByteArray());
settings.endGroup();
When a close event is called:
Code:
// Main window settings
settings.beginGroup("mainWindow");
settings.setValue("geometry", saveGeometry());
settings.setValue("splitterState", splitter->saveState());
settings.endGroup();
The splitter always starts in the middle, regardless of where I leave it at close.
Any help?
Re: QSplitter::restoreState() not working
Hi PeterThePuter,
I also tested this and noticed that you can correctly save into QSettings object only if you define the organizationName on the QApplication object.
Something like this:
Code:
a.setOrganizationName("TestSplitter");
Re: QSplitter::restoreState() not working
Hello,
I have exactly the same issue. The issue is not in saving the
QSplitter state. I am sure that the data is well stored and read
from my settings file.
The issue is that, in some case, the QSplitter is not restored.
PeterThePuter, did you solve that issue?
Thanks