summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-11-01 20:30:50 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-11-20 20:48:59 +0100
commitc63669bb8c5169f8232151451b1095e2f3013d48 (patch)
tree5d14c51ff51a92e94e002265ea99e9aab15fe0c0 /src
parenta31484302d71c29c0e0e62f9941f9d5f0c87f9aa (diff)
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 <samuel.gaist@idiap.ch>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qlayout.cpp13
-rw-r--r--src/widgets/kernel/qlayout.h1
2 files changed, 14 insertions, 0 deletions
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
@@ -353,6 +353,19 @@ void QLayout::setContentsMargins(const QMargins &margins)
}
/*!
+ \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
For each of \a left, \a top, \a right and \a bottom that is not
diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h
index 0377aa62b3..4686a999a5 100644
--- a/src/widgets/kernel/qlayout.h
+++ b/src/widgets/kernel/qlayout.h
@@ -85,6 +85,7 @@ public:
void setContentsMargins(int left, int top, int right, int bottom);
void setContentsMargins(const QMargins &margins);
+ void unsetContentsMargins();
void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
QMargins contentsMargins() const;
QRect contentsRect() const;