Adjust Spacing and Margins between Widgets in Layout

From Qt Wiki
Revision as of 08:02, 4 March 2015 by AutoSpider (talk | contribs) (Convert ExpressionEngine links)
Jump to navigation Jump to search


English | Deutsch [toc align_right="yes" depth="2"]

Adjust Spacing and Margins between Widgets in Layout

Overview

To adjust margins and spacing between widgets use the following methods setSpacing() and setContentsMargins() that are implemented in class QLayout.

Example

This code snippet shows how to remove spacing and margins between widgets in instance of QVBoxLayout

pLayout = new QVBoxLayout(this);
pLayout->setSpacing(0);
pLayout->setMargin(0);
pLayout->setContentsMargins(0,0,0,0);
pLayout->addWidget(m_pLabel, 0, Qt::AlignTop);
pLayout->addWidget(m_pButton, 0, Qt::AlignTop);
setLayout(pLayout);