Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

Adjust Spacing and Margins between Widgets in Layout: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Localisation)
(convert {{doclinkanchorlbl}} to the improved {{doclink}})
Line 2: Line 2:
{{LangSwitch}}
{{LangSwitch}}
== Overview ==
== Overview ==
To adjust margins and spacing between {{DocLink|QWidget}}s use the following methods {{DocLinkAnchorLbl|QLayout|spacing-prop|setSpacing}} and {{DocLinkAnchorLbl|QLayout|contentsMargins|setContentsMargins}} that are implemented in class {{DocLink|QLayout}}.
To adjust margins and spacing between {{DocLink|QWidget}}s use the following methods {{DocLink|QLayout|spacing-prop|setSpacing}} and {{DocLink|QLayout|contentsMargins|setContentsMargins}} that are implemented in class {{DocLink|QLayout}}.


== Example ==
== Example ==

Revision as of 09:35, 23 October 2015

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

Overview

To adjust margins and spacing between QWidgets 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);