From 88e56d0932a3615231adf40d5ae033e742d72c33 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 21 Jun 2017 10:05:07 +0200 Subject: Improve rounding of QRect::toRect Avoid the dimensions of the rounded QRect being off by more than one pixel. This ensures the aligned containing rect also contains the rounded rect. Task-number: QTBUG-56420 Change-Id: Ib79110e51ab80de2dc83d01ea83fc5fbf3852e75 Reviewed-by: Thiago Macieira --- src/corelib/tools/qrect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/tools/qrect.h') diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 19ff87b420..3b40055b5a 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -870,7 +870,7 @@ Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &r1, const QRectF &r2) Q_DE Q_DECL_CONSTEXPR inline QRect QRectF::toRect() const Q_DECL_NOTHROW { - return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h)); + return QRect(QPoint(qRound(xp), qRound(yp)), QPoint(qRound(xp + w) - 1, qRound(yp + h) - 1)); } Q_DECL_CONSTEXPR inline QRectF operator+(const QRectF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW -- cgit v1.2.3