PDA

View Full Version : initial size of docked window



GrahamLabdon
28th February 2011, 15:21
Hi

Can anyone please tell me how to set the initial size of a docked widget?

TIA

Graham

agarny
28th February 2011, 15:38
As far as I know, you can't set an initial size, since the size of a docked widget is dependent on its contents. So, what you can do instead is to override the virtual sizeHint() (http://doc.qt.nokia.com/latest/qwidget.html#sizeHint-prop) function of any children widget. That's what I personally do and what allows me to 'control' the initial size of a docked widget.

GrahamLabdon
28th February 2011, 16:22
Hi thanks for the reply
I am using QDesigner and have docked widget with QListWidget child and have set up the list items in designer.
When I run the application the docked widget is very narrow - it is not setting its size according to the contents.
If I hand code the same scenario the docked widget has the required size i.e. it is resized to the largest list item
Any idea why this would be the case?

agarny
28th February 2011, 16:33
I imagine that it must have something to do with when exactly Qt determines the size of your docked widget. In the former case, it clearly determines the size before any item is added to the list, while in the latter case it does it after the items have been added. Interesting... and I am not sure how you could address that issue. (I am relatively new to Qt, sorry.)