I save the state of one of my QSplitter like that:
self.options.setValue("Window/final_splitter", self.splitter2.saveState())
And I restore it like that:
self.splitter2.restoreState(self.options.value("Window/final_splitter"))
When I save the splitter, splitter2.sizes() indicates: [321, 818, 769]
When I restore the splitter, it has visually the same dimensions as when I closed it, but splitter2.sizes() indicates: [224, 572, 537]
And I can't perform more actions on the splitter because I can't get its size right.
Do you have any idea about how to solve this bug ?
EDIT: even more odd:
saving:
self.options.setValue("Window/final_splitter", self.splitter2.sizes())
-> self.splitter2.sizes(): [321, 844, 743]
Restoring:
sizes_splitter2 = [int(nbr) for nbr in self.options.value("Window/final_splitter", [])]
self.splitter2.setSizes(sizes_splitter2)
- sizes_splitter2: [321, 844, 743]
- self.splitter2.sizes(): [224, 590, 519]
EDIT 2: When I save the splitter, I also do (self is a QMainWIndow):
self.options.setValue("window_geometry", self.saveGeometry())
self.options.setValue("window_state", self.saveState())
If I comment those lines, the splitter.sizes() returns the good values. But those 2 lines do their job, the window is restored to the right size with them !