PDA

View Full Version : Zero-size expanding Spacer, some way to top align in a group-box



mortoray
20th May 2011, 13:37
I have a layout like this:

Widget (Vertical)
-Box (Horizontal)
--Some Group Boxes (Vertical/Grid)
---labels, radio, edits
-Box (Horizontal)
-QTableWidget

I want all the items in the group boxes to the be top-aligned. The most obvious solution is to add a spacer at the bottom of each of them, but this increases the size of the group boxes. The QTableWidget is supposed to take all available extra space, and the other items the minimum available space.

Is there any combination of flags/spacers/layouts I can use to get the items in the group boxes top-aligned without increase the size of those boxes?

Santosh Reddy
20th May 2011, 17:36
Ok, What you expect is the default behaviour, you just need take of one thing.

If using QtCreator to design the form, make sure that all the Container Widget's Layouts are set to QGridWidget (or at least the top level), this can be done by right click on the top level container Widget and Lay out >> Lay out in a Grid Ctrl+G

If Using Custom code to generate the form, make sure the atleast the top level (which contains the QTableWidget) has QGridLayout() or QVBoxLayout, which ever is relavent to you.

I have created a sample using QtCreator, it should be simple if already have hands on with QtDesigner.

6455