diff options
-rw-r--r-- | src/corelib/tools/qmargins.h | 18 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qmargins/tst_qmargins.cpp | 6 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index 0d68be961e..ad5e94cefe 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -242,6 +242,24 @@ inline QMargins &QMargins::operator-=(const QMargins &margins) return *this = *this - margins; } +inline QMargins &QMargins::operator+=(int margin) +{ + m_left += margin; + m_top += margin; + m_right += margin; + m_bottom += margin; + return *this; +} + +inline QMargins &QMargins::operator-=(int margin) +{ + m_left -= margin; + m_top -= margin; + m_right -= margin; + m_bottom -= margin; + return *this; +} + inline QMargins &QMargins::operator*=(int factor) { return *this = *this * factor; diff --git a/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp b/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp index d22e771b79..ec83740196 100644 --- a/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp +++ b/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp @@ -93,6 +93,12 @@ void tst_QMargins::operators() a -= m2; QCOMPARE(a, subtracted); + QMargins h = m1; + h += 2; + QCOMPARE(h, QMargins(14, 16, 18, 20)); + h -= 2; + QCOMPARE(h, m1); + const QMargins doubled = m1 * 2; QCOMPARE(doubled, QMargins(24, 28, 32, 36)); QCOMPARE(2 * m1, doubled); |