PDA

View Full Version : zero'ing margin in a qhboxlayout



illuzioner
2nd July 2007, 05:54
i've got a simple widget that contains 2 children: a stackedwidget and a button. i applied a horizontal layout to it and was able to make all the margins zero.

in the stackedwidget, there is a single lineedit on one page and a date/time edit on the other page, both with horizontal layouts. with these layouts, however, i can't seem to zero out the margins. this causes part of the lineedit or date edit to be cut off when the widget is a certain height, which it's supposed to be. i attached the ui file for reference. i just want the entire widget to be the exact height of the lineedit.

how do i zero out these margins?

thanks! -- lou

jpn
2nd July 2007, 09:32
Make sure that

stacked layout of stacked widget has zero margins (AFAIK not possible via designer)
page layouts have zero margins (in designer select pages from object inspector and set /Layout/Margin property)

The following code would do this:


stackedWidget->layout()->setMargin(0); // 1.
for (int i = 0; i < ui.stackedWidget->count(); ++i)
stackedWidget->widget(i)->layout()->setMargin(0); // 2. (assumes that pages have layout installed)

illuzioner
2nd July 2007, 11:30
Make sure that

stacked layout of stacked widget has zero margins (AFAIK not possible via designer)
page layouts have zero margins (in designer select pages from object inspector and set /Layout/Margin property)

The following code would do this:


stackedWidget->layout()->setMargin(0); // 1.
for (int i = 0; i < ui.stackedWidget->count(); ++i)
stackedWidget->widget(i)->layout()->setMargin(0); // 2. (assumes that pages have layout installed)

does setmargin exist in qt4? i looked in the documentation and only found it in q3 residual classes. i couldn't find in the docs how to set the margin. any ideas?

thanks! -- lou

jpn
2nd July 2007, 11:54
QLayout::setMargin() (http://doc.trolltech.com/4.2/qlayout.html#margin-prop) was made obsolete in Qt 4.3. Documentation proposes using QLayout::setContentsMargins() (http://doc.trolltech.com/4.3/qlayout.html#setContentsMargins) instead.