[PyQt] Newbie resizing dock widgets question

Sarah Mount mount.sarah at gmail.com
Tue Apr 26 23:45:58 BST 2011

On Tue, Apr 26, 2011 at 21:45, David Boddie <david at boddie.org.uk> wrote:
> On Mon Apr 25 21:50:43 BST 2011, Sarah Mount wrote:
>> In designer-qt4 the object inspector, widget box and so on seem to be
>> QDockWidgets. I'm making a GUI in Designer that I want to be similarly
>> structured. In designer the edge of each QDockWidget can be grabbed
>> with the mouse and resized, but in my GUI this isn't possible. I
>> *think* I've set all of the dockWidget properties and the widgets can
>> be closed and floated, but not resized. Have I misunderstood this? Is
>> there some sort of splitter object that needs to be placed between the
>> dockWidgets? Or some property set in the layout managers?
> Which version of Qt Designer are you using? Did you manually place the
> dock widget into a layout?

This is Designer 4.7.2 on Ubuntu Natty and the docks are going inside
a Main Window widget, with a grid layout applied to them.

> In older versions of Qt Designer, dropping a dock widget onto a main window
> form simply left it floating, unmanaged, unless the central area was
> managed by a layout. In newer versions, the dock window is automatically
> docked by default - at least, it seems that way.
> If you have a dock window embedded in a main window, and you can't move it
> when you preview the form, try breaking the layout of the window, selecting
> the dock widget, and setting its docked property to true. It should appear
> in one of the dock areas around the sides of the window and be handled
> separately to the widgets in the main window itself.

This seems to be the problem, and like you say, if I break the layout
and set the widgets to docked they become resizable, oddly.

However, I have three QDockWidgets, one that is intended to stretch
over the bottom of the main window, and the other two above it side by
side, like this:

[  ]

I've set all of the sizePolicy properties to Expanding; the lower
dockWidget expands correctly both horizontally and vertically. The top
two widgets will expand vertically but leave a large gap in the centre
of the main window when resizing the main window horizontally. This
worked just fine when I was applying a grid layout to the
centralWidget. Any ideas? It all seems a bit counter-intuitive to me!

Many thanks again,


Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2

More information about the PyQt mailing list