Discussion:
Newbie resizing dock widgets question
Sarah Mount
2011-04-25 20:50:43 UTC
Permalink
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?

Thanks for your help,

Sarah
--
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
David Boddie
2011-04-26 20:45:48 UTC
Permalink
Post by Sarah Mount
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?

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.

David
GOO Creations
2011-04-26 21:08:35 UTC
Permalink
Make sure you are using a QMainWindow. Adding a dock widget to a QDialog
my result in problems such as non-movable, non-resizeable, etc
Post by David Boddie
Post by Sarah Mount
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?
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.
David
_______________________________________________
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Sarah Mount
2011-04-26 22:45:58 UTC
Permalink
Post by David Boddie
Post by Sarah Mount
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.
Post by David Boddie
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
--
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
Andreas Pakulat
2011-04-26 23:10:59 UTC
Permalink
Post by Sarah Mount
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
[][]
[ ]
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!
Sounds like you're using the wrong tool for the job. dock widgets are
supposed to be moveable around the 4 areas above, below and next to the
central area. The intent is to have a central widget or widgets and the
dock-areas contain helper tools for working on the central widget. If
all you want is one widget stretched alongside the bottom and two above
that share the space, then use normal widgets and a grid-layout for
that.

Andreas
Sarah Mount
2011-04-26 23:14:15 UTC
Permalink
Post by Andreas Pakulat
Post by Sarah Mount
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
[][]
[  ]
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!
Sounds like you're using the wrong tool for the job. dock widgets are
supposed to be moveable around the 4 areas above, below and next to the
central area. The intent is to have a central widget or widgets and the
dock-areas contain helper tools for working on the central widget. If
all you want is one widget stretched alongside the bottom and two above
that share the space, then use normal widgets and a grid-layout for
that.
The two top widgets are QScintilla widgets, I wanted them to be
resizable and closable so you can choose to only edit one pane at a
time. As I understand it, QDockWidgets are the only widgets that have
those properties, or am I wrong?

Thanks,

Sarah
--
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
David Boddie
2011-04-26 23:17:49 UTC
Permalink
Post by Sarah Mount
Post by David Boddie
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.
OK. You should try to avoid using layouts to arrange the dock widgets
themselves. It's fine to arrange the contents of the dock widgets using
layouts, of course.
Post by Sarah Mount
Post by David Boddie
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.
Yes, this sounds like they were placed in the central area of the main
window and arranged using a layout.
Post by Sarah Mount
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
[][]
[ ]
OK, it sounds like you need to tell the top two dock widgets to occupy
the top area - set their dockWidgetArea properties to TopDockWidgetArea
in the property editor and check their docked properties. The other dock
widget should be placed in the BottomDockWidgetArea.
Post by Sarah Mount
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?
Using the instructions above, you should now be able to resize them to fill
the window in the way you want, but I'm not sure if it's possible to get
them to expand in the way you describe. It depends on what they contain.
Post by Sarah Mount
It all seems a bit counter-intuitive to me!
Maybe the diagram on this page will help to explain things:

http://doc.qt.nokia.com/4.7/mainwindow.html

The "center widget" or central area in the main window is a normal widget
that you can place any other widgets in. This includes dock widgets, but
they aren't designed to be used like that. They are supposed to be managed
separately by the main window, "outside" the central area. Qt Designer does
a reasonable job of letting you configure this, but it is constrained by its
widgets-on-a-form approach to UI design.

If it turns out that you aren't using all the features of dock widgets in
your application, you can design the kind of UI you describe using splitters
instead. If you want to do that, just ask and I can give more details.

David
Sarah Mount
2011-04-26 23:50:14 UTC
Permalink
<snip: long docking discussion>
Post by David Boddie
The "center widget" or central area in the main window is a normal widget
that you can place any other widgets in. This includes dock widgets, but
they aren't designed to be used like that. They are supposed to be managed
separately by the main window, "outside" the central area. Qt Designer does
a reasonable job of letting you configure this, but it is constrained by its
widgets-on-a-form approach to UI design.
If it turns out that you aren't using all the features of dock widgets in
your application, you can design the kind of UI you describe using splitters
instead. If you want to do that, just ask and I can give more details.
Thanks, that diagram made a lot of sense, I've re-worked the GUI with
splitters, and, like you say, that's much more what I was looking for.
I didn't realise that splitters could be resized, and I can add some
actions for closing each pane.

Many thanks,

Sarah
--
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
Andreas Pakulat
2011-04-27 06:27:30 UTC
Permalink
Post by Sarah Mount
<snip: long docking discussion>
Post by David Boddie
The "center widget" or central area in the main window is a normal widget
that you can place any other widgets in. This includes dock widgets, but
they aren't designed to be used like that. They are supposed to be managed
separately by the main window, "outside" the central area. Qt Designer does
a reasonable job of letting you configure this, but it is constrained by its
widgets-on-a-form approach to UI design.
If it turns out that you aren't using all the features of dock widgets in
your application, you can design the kind of UI you describe using splitters
instead. If you want to do that, just ask and I can give more details.
Thanks, that diagram made a lot of sense, I've re-worked the GUI with
splitters, and, like you say, that's much more what I was looking for.
I didn't realise that splitters could be resized, and I can add some
actions for closing each pane.
Splitters also allow to close the pane with an easy way to re-open it
later. See the childrenCollapsible property, which defaults to true.

Andreas

Loading...