Add missing operators QMargins -=,+= (int).

Task-number: QTBUG-34079

Change-Id: If61cc01ba70345b01f13072769d3a38f23e8cefc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Friedemann Kleint 2013-10-15 10:18:22 +02:00 committed by The Qt Project
parent a3a1bd755f
commit 8178a6cab1
2 changed files with 24 additions and 0 deletions

View File

@ -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;

View File

@ -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);