PDA

View Full Version : Weird behaviour in restoring the state and geometry of a QMainWindow with QDockWidget



xhoch3
29th May 2012, 10:03
Hello everyone,

My System is Ubuntu 12.04 64 Bit with Qt 4.8.1.

I have a QMainWindow with several dock widgets and a hidden central widget, because as the documentation states a QMainWindow without a central widget is not supported. Every dock widget has been assigned an object name. I save the QMainWindow's state and geometry with:


settings->setValue ("MainWindow/geometry", saveGeometry ());
settings->setValue ("MainWindow/windowState", saveState ());
settings->sync ();

and restore it with the following commands:


restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ());
restoreState (settings->value ("MainWindow/windowState").toByteArray ());

which is the last thing that I call in my QMainWindow constructor.

Just in case: Since this is a GPL project, you can see the full source code here on branch gui, in the subfolder gui. If you need any excerpts, don't hesitate to ask.

hg clone http://hg.savannah.gnu.org/hgweb/octave/

The problem now is, that the central widget now gets centered after restoring the previous state. I tried barely everything, in the end I even save and restored the geometry myself. I have made two screenshots that may clarify what I mean:

This is before saving the state:
http://www7.pic-upload.de/thumb/29.05.12/3sdj6dkl67jk.png (http://www.pic-upload.de/view-14408544/Bildschirmfoto-vom-2012-05-29-10-50-10.png.html)

This is after restoring, the command window gets shifted to the right, because it is in the RightDockWidgetArea and the central widget (which is hidden), gets centered.
http://www7.pic-upload.de/thumb/29.05.12/6rwsj4wniuib.png (http://www.pic-upload.de/view-14408554/Bildschirmfoto-vom-2012-05-29-10-50-38.png.html)

Any ideas on this?