PDA

View Full Version : QHBoxLayout Problem



Seema Rao
26th April 2006, 11:40
QWidget *window = new QWidget;
QPushButton *button1 = new QPushButton("One");
QPushButton *button2 = new QPushButton("Two");

QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(button1);
layout->addWidget(button2);


Can some body explain how to specify space between each widgets that are added to QHBoxLayout?

Thanks in advance,
Seema Rao

jpn
26th April 2006, 11:48
void QBoxLayout::addSpacing ( int size ) (http://doc.trolltech.com/4.1/qboxlayout.html#addSpacing)
void QBoxLayout::addStretch ( int stretch = 0 ) (http://doc.trolltech.com/4.1/qboxlayout.html#addStretch)

jcr
26th April 2006, 14:22
addSpacing adds space at the end of the layout
setSpacing adds space between widgets inside the layout

cocalele
27th April 2006, 07:08
May be Qt should have a FormLayout like SWT

jpn
27th April 2006, 07:27
You mean something like the Border Layout Example (http://doc.trolltech.com/4.1/layouts-borderlayout.html)?

cocalele
29th April 2006, 15:51
Yes, BorderLayout is simple and easy to use. But I also want a FormLayout which is more flexibility. If you have used Java/Eclipse/SWT, you will know the FormLayout. And I think the BorderLayout and FormLayout should be part of the Qt library but not supplied in the example.