[Qt-interest] Fwd: How to alter QVBoxLayout widget spacing ?

Stephen Collyer scollyer at netspinner.co.uk
Wed Feb 17 16:18:45 CET 2010


On 17 February 2010 15:03, Alexandre Beraud <aberaud at infflux.com> wrote:

> Hi,
>
> According to your screenshot the margins are now zero (the widgets stick
> to the top and left sides of the window) but the spacings are not null.
> Make sure that you set the spacings of the horizontal and vertical
> layouts to zero.
>
>
Alex, vous avez raison. I'm an idiot. I had commented out the setSpacing()
calls, and forgotten about it. The code now looks like:

ParagraphRow::ParagraphRow(Row row,
                           QWidget* parent)
{
    QHBoxLayout* para_row_layout = new QHBoxLayout;
    para_row_layout->setSpacing(0);
    para_row_layout->setContentsMargins(0,0,0,0);
...
}

ParagraphList::ParagraphList(const QList<ParagraphRow *>& para_rows,
                             QWidget* parent)
                : QWidget(parent)
{
    QVBoxLayout* para_list_layout = new QVBoxLayout;
    para_list_layout->setSpacing(0);
    para_list_layout->setContentsMargins(0,0,0,0);
...
}

which gives the following result:

http://dl.dropbox.com/u/4271762/snapshot3.png

Thanks for the help, everyone.

I love Qt's layout system. It gives me hours of fun, everytime I try to use
it.

-- 
Stephen Collyer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100217/10087b07/attachment.html 


More information about the Qt-interest-old mailing list