diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-04-21 15:25:49 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-04-21 22:13:11 +0200 |
commit | 284d4e71258ad3afeda6d5bb83eb50e25137824c (patch) | |
tree | df3534ab91edd9f0c947c86d767d37e1f2f59633 /tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp | |
parent | 1a65a4faf52f83ba3fbbba88cea1c4bb800e8de7 (diff) |
QLayout: mark unsetContentsMargins as the RESET function
contentsMargins is a Q_PROPERTY on a QLayout. Qt 6.1 introduced
QLayout::unsetContentsMargins() to reset the contents margins to the
"default" ones (that the user can't know); that's the textbook
description of a RESET function for the property.
Add some tests also for unsetContentsMargins.
[ChangeLog][QtWidgets][QLayout] The unsetContentsMargins() function now
acts as the RESET function for the contentsMargins property.
Change-Id: I463d88363c11f4a15ad3d6af71401d8698de1d41
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp')
-rw-r--r-- | tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp index 2a497df084..01b7c8ef9c 100644 --- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp +++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp @@ -30,6 +30,7 @@ #include <QTest> #include <qcoreapplication.h> +#include <qmetaobject.h> #include <qdebug.h> #include <qboxlayout.h> #include <qmenubar.h> @@ -248,6 +249,22 @@ void tst_QLayout::setContentsMargins() layout.setContentsMargins(52, 53, 54, 55); QVERIFY(!layout.invalidated); + + MyLayout otherLayout; // with default contents margins + QVERIFY(layout.contentsMargins() != otherLayout.contentsMargins()); + layout.unsetContentsMargins(); + QCOMPARE(layout.contentsMargins(), otherLayout.contentsMargins()); + + layout.setContentsMargins(10, 20, 30, 40); + QVERIFY(layout.contentsMargins() != otherLayout.contentsMargins()); + + int contentsMarginsPropertyIndex = QLayout::staticMetaObject.indexOfProperty("contentsMargins"); + QVERIFY(contentsMarginsPropertyIndex >= 0); + QMetaProperty contentsMarginsProperty = QLayout::staticMetaObject.property(contentsMarginsPropertyIndex); + QVERIFY(contentsMarginsProperty.isValid()); + QVERIFY(contentsMarginsProperty.isResettable()); + QVERIFY(contentsMarginsProperty.reset(&layout)); + QCOMPARE(layout.contentsMargins(), otherLayout.contentsMargins()); } class EventReceiver : public QObject |