PDA

View Full Version : QDockWidget and Qt Creator designer



x-treem
2nd September 2016, 17:32
I'm starting to learn some Qt and my background is mostly embedded software and C# for quick tools with UI. I cant make much sense of the geometry/size policies/minimum size/maximum size so I started fiddling around, nothing better than some field testing no?

Now I create a brand new project, open the Qt Creator designer, add a QDockWidget on the left side of the QMainWindow, then I hover on the QDockWidget right side and increase the size of the dock widget to 150pixels, add 3 buttons and manually position them in the dock window in the very middle. Now my thinking here is very WYSWYG. So i decide, lets run and see what happens.

To my very disappointment "what i see is not what i get"... The size of the QDockWidget when I run the app is the same as when I dropped it, before hovering ad making it wider...and the push-buttons are cut right in the middle.

I might be a newb, I might be picky but right now I don't really understand why the designer is showing me something and at run-time the app is doing something else.

anda_skoa
2nd September 2016, 18:47
Normally you will get what you see, however, it could be that the QDockWidget, since it is a special kind of container, has some runtime resizing code and attempts to resize to its content.

If your content is not properly layouted, then it will not "see" the content's requirements and fall back to some default size.
You could override that by e.g. setting a minimum width, but ideally you'll fix the layout.

Cheers,
_