PDA

View Full Version : QSpacerItem constructor arguments



Defeatist
10th February 2010, 19:10
Hi! I'm not sure what values to use in the following situation:


verticalSpacer = new QSpacerItem(/*???*/); // Not sure what to make of this

verticalLayout_2 = new QVBoxLayout();
verticalLayout_2->addWidget(advancedButton);
verticalLayout_2->addWidget(addButton);
verticalLayout_2->addWidget(removeButton);
verticalLayout_2->addSpacerItem(verticalSpacer);

If I simply add two integers for w and h it works but not as I want it; I want it to push the 3 buttons completely together regardless of the window size

The description on the online documentation confuses me

QSpacerItem::QSpacerItem ( int w, int h, QSizePolicy::SizeType hData = QSizePolicy::Minimum, QSizePolicy::SizeType vData = QSizePolicy::Minimum )

Constructs a spacer item with preferred width w, preferred height h, horizontal size policy hData and vertical size policy vData.

The default values provide a gap that is able to stretch if nothing else wants the space.

How do I make verticalSpacer take up all available space in the vertical direction?

Thanks in advance

mcosta
12th February 2010, 12:53
use



QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);


w and h parameters are preferred dimension. Using QSizePolicy::Expanding for vertical size policy you can obtain what you want.