PDA

View Full Version : KXmlGuiWindow + QDockWidget + fullscreen = resize problem on restart



Valheru
10th August 2008, 13:38
This problem occurs with a subclassed KXmlGuiWindow which has a QDockWidget displayed on either it's left or right sides. The central widget is a QTreeView, not that it matters.
The application autosaves the window positions and sizes. The following behavious only occurs when the application is closed with the dock window displayed and it was maximized:

When the application restarts, it tries to resize to the fullscreen size, in my case 1650x1080. But in the applications rc file, the main window sizes are reported to be:



[MainWindow]
Height 1050=1051
Width 1680=1681


As you can see, the sizes are off by one pixel. The causes the application to very breifly resize to fullscreen+1, and then it resizes to a very small (default) size. The problem is obviously alleviated somewhat by specifying a suitably large default size, but what one really wants is the application to resize properly. Does anyone know a solution for this problem? As I have specified, it is only caused when the dock widget is displayed: hiding the dock widget causes the application to resize normally upon restart. I have not specifically saved the dock widgets size on shutdown: since it is a child widget of the main window all of it's attributes are saved automatically.

Valheru
10th August 2008, 19:55
Well, I fixed the problem in a totally unexpected way. I designed the widget that I was embedding in QDockWidget in Designer ( it was a simple widget with 4 buttons in it in a QVBoxLayout, with a QHBoxLayout as the widgets layout, with spacers at the extremes of both layouts to keep the buttons centered no matter how large the widget was resized). Wonder of wonders, the resize error went away. I compared the code generated by uic to my code, and there was no obvious differences, but the error went away. I am guessing it was some sort of parenting problem that I failed to see or something similar, but I am just guessing.
Anyway, the problem was solved, so if anyone comes looking, this may help you.