1 Attachment(s)
zero'ing margin in a qhboxlayout
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
Re: zero'ing margin in a qhboxlayout
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:
Code:
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)
Re: zero'ing margin in a qhboxlayout
Quote:
Originally Posted by
jpn
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:
Code:
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
Re: zero'ing margin in a qhboxlayout
QLayout::setMargin() was made obsolete in Qt 4.3. Documentation proposes using QLayout::setContentsMargins() instead.