[Qt-interest] More struggles with layouts and resizing -- QGroupBox gets squashed

Andreas Pakulat apaku at gmx.de
Sun Mar 28 21:57:16 CEST 2010


On 28.03.10 11:48:13, K. Frank wrote:
> I'm still trying to figure out how to use resizing most effectively.
> I will give a
> concrete example and ask a general question.
> 
> The example:
> 
> I layout a form that contains a QGroupBox, but the QGroupBox (and its contents)
> get squashed.
> 
> I create a new QWidget-based form in designer, and drop a QTableView onto it
> towards the bottom.
> 
> In case a, I add two QRadioButton's, one above the other, above the QTableView,
> and group them together into a vertical layout.
> 
> In case b, I add a QGroupBox above the QTableView, and then add two
> QRadioButton's
> to the QGroupBox.
> 
> I now set the top-level layout of the QWidget to a vertical layout.
> In case a (the
> two QRadioButton's are in a vertical layout), everything resizes nicely:  The
> QTableView takes up most of the space, with the two QRadioButton's nicely
> sized above it.
> 
> In case b (the QRadioButton's are in a QGroupBox), the QTableView expands
> (as expected), but the QGroupBox shrinks down to the point that only its title
> is visible, and its contents (the QRadioButton's) are hidden.

Check again where you got "QGroupBox" from on the left "widgets" list.
Its in the "Container" group, meaning that it itself can contain
widgets. As a widget-container it also can have a layout and thats what
you apparently didn't set. If a QGroupBox has no layout it behaves much
the same as a top-level widget without layout when you resize it to a
minimal size.

Andreas

-- 
You will engage in a profitable business activity.



More information about the Qt-interest-old mailing list