[Qt-interest] How does Qt designer manage resizing widgets at design time?

K. Frank kfrank29.c at gmail.com
Sun Mar 21 23:46:43 CET 2010


Hello All -

Or maybe I should be asking how can I manage resizing widgets at design time.

This is a follow-up question to comment Sean made in a previous thread:

>> Is there any (easy) way to get
>> my place-holder widget (in my test case, a QWidget) to mimic in Qt designer
>> more closely QTableWidget (or my custom widget)?
>
> A simple work-around for the sizing of promoted widgets issue in
> designer is to manually alter the size policy for the widget.
>
> Sean

This is not that big a deal for me -- it's a matter of minor convenience, and
more importantly to help me better learn the tricks of the Qt trade.

To be concrete, in Qt designer, I drop a QTreeView, a QTableWidget, and
a QTableView, from left to right in that order onto a form, I group the three
widgets together in a horizontal layout, and I apply a vertical layout to the
background (central widget?) of the form.  The three widgets now take up
most of the space of the form, are about the same size, and resize
proportionately when I resize the form.  (This is all at design time.)

If I replace the QTableWdiget with a QWidget (that is, I drop a QTreeView,
a QWidget, and a QTableView onto a blank form, and set the layouts, etc.),
the QWidget is much skinnier than the other two widgets.

(What I really want is a custom widget that contains a QTableWdiget, so
I am using the QWidget as a place-holder in Qt designer, and promoting
it to my custom widget.)

If I select the QWidget and use the Property Editor to set its sizePolicy
to "Expanding, Expanding" (from "Preferred, Preferred", to match the
sizePolicy of the other two widgets), it gets somewhat wider, but still
not as wide as the other two widgets.  I can also set the minimumSize
to a value of my choice, so I can make my form look more realistic in
designer, but the QWidget place-holder still doesn't resize the way the
other two widgets do.

Again, this is certainly good enough for my practical needs, but I would
like to follow up on Sean's comment, and ask if it is possible to tweak
my QWidget place-holder so that behaves more realistically in designer.

What confuses me a little is that when I use the Property Editor to look
at the various properties of the three widgets, I don't see and size-related
differences (after I set the sizePolicy for the QWidget to "Expanding,
Expanding"), so I don't see any simple reason for them to act differently
in designer.

Any wisdom would be appreciated.

Thanks.


K. Frank



More information about the Qt-interest-old mailing list