From c63669bb8c5169f8232151451b1095e2f3013d48 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 1 Nov 2020 20:30:50 +0100 Subject: QLayout: add a way to unset user-defined contents margins Once user-defined margins are set on a layout, there's no way to unset them, except by abusing setContentsMargins and passing -1, which is a total API abuse (does a negative margin mean that contents *overflow* the layout?). Add a proper function. [ChangeLog][QtWidgets][QLayout] Added unsetContentsMargins(). Change-Id: I089788a7470f9649a8f00e42914dafb7242f12cd Reviewed-by: Samuel Gaist --- src/widgets/kernel/qlayout.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/widgets/kernel/qlayout.cpp') diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index db7aa1aaeb..39c7f7ec3f 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -352,6 +352,19 @@ void QLayout::setContentsMargins(const QMargins &margins) setContentsMargins(margins.left(), margins.top(), margins.right(), margins.bottom()); } +/*! + \since 6.1 + + Unsets any user-defined margins around the layout. The layout will + use the default values provided by the style. + + \sa setContentsMargins() +*/ +void QLayout::unsetContentsMargins() +{ + setContentsMargins(-1, -1, -1, -1); +} + /*! \since 4.3 -- cgit v1.2.3