diff options
author | John Layt <jlayt@kde.org> | 2014-02-15 16:07:52 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-21 20:33:10 +0100 |
commit | c7aa3a69253c82b8ae814c88ebbdfad7e48d0b2d (patch) | |
tree | 3219f573b3eeb7a1d0f1987f51920231f4e58453 /src/corelib | |
parent | 9c6447e0815a18102e5ebe236c52ba4343dbb8fa (diff) |
QRect - Add missing QMargins subtraction operator
[ChangeLog][QtCore][QRect] Added QMargins subtraction operator.
Change-Id: I64d449e2bae81a34df2cd019cff3fb186f8aaaae
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qrect.cpp | 9 | ||||
-rw-r--r-- | src/corelib/tools/qrect.h | 6 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index e67b74ea6c..e3ecdbb2ca 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -1182,6 +1182,15 @@ bool QRect::intersects(const QRect &r) const */ /*! + \fn QRect operator-(const QRect &lhs, const QMargins &rhs) + \relates QRect + + Returns the \a lhs rectangle shrunken by the \a rhs margins. + + \since 5.3 +*/ + +/*! \fn QRect QRect::marginsAdded(const QMargins &margins) const Returns a rectangle grown by the \a margins. diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 52f1a79362..5f59bde269 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -463,6 +463,12 @@ Q_DECL_CONSTEXPR inline QRect operator+(const QMargins &margins, const QRect &re QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); } +Q_DECL_CONSTEXPR inline QRect operator-(const QRect &lhs, const QMargins &rhs) +{ + return QRect(QPoint(lhs.left() + rhs.left(), lhs.top() + rhs.top()), + QPoint(lhs.right() - rhs.right(), lhs.bottom() - rhs.bottom())); +} + Q_DECL_CONSTEXPR inline QRect QRect::marginsAdded(const QMargins &margins) const { return QRect(QPoint(x1 - margins.left(), y1 - margins.top()), |