PDA

View Full Version : Quick spacing question



bruccutler
8th March 2007, 20:38
I just don't get the spacing options with Qt.

I have a widget and I want to put three buttons at the bottom of the widget. Now, however, the three buttons are taking up all the space along the bottom of the window. I've tried adding spacing, via addSpacing(1) both before and after the buttons, but they still take the full space. I've tried setting the align option on the addWidget() to Qt:AlignCenter to the center one and AlignLeft to the left one and alignRight to the right one. I've tried setting the stretch to -1, but nothing works.

What's the trick?
-BRC

bruccutler
8th March 2007, 20:41
Maybe I've figured it out - I'm now using addStretch on both sides.


Right?

smacchia
8th March 2007, 20:43
An alternative to that is to put the buttons in a QHBoxLayout or QGridLayout, then add QSpacerItem instances to each side using the ::addItem method on the layout.

HTH,
Susan

wysota
8th March 2007, 20:44
Maybe I've figured it out - I'm now using addStretch on both sides.

Right?

Right.

You could have also changed size policies of the buttons (for example to "fixed"), so that they wouldn't expand to fill all the space available.

bruccutler
8th March 2007, 20:46
Right. But the real problem is that you didn't set size policies properly.

Suggestion? How do I set the size policies? I'm coding these by hand. I'll go look them up, but maybe you can asisst?
- BRC