From 8f601bf85748ca62344c5dbaef2f3dd941a16466 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 25 Mar 2010 10:32:49 +0100 Subject: Fix QLabel::sizeHint() The QTextControl case of QLabel calculated the bounding rect of the label by taking the size of the control (floating point) and using toSize() to convert this to an integer QSize. While this would work when the font engine always returned integer values, it is not the correct way to calculate a bounding rect, since the bounding rect needs to contain all the pixels of the text, including the ones that are only partially covered, thus its size should never be rounded down. Reviewed-by: Olivier --- src/gui/widgets/qlabel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp index b81f04f..bdbd0b0 100644 --- a/src/gui/widgets/qlabel.cpp +++ b/src/gui/widgets/qlabel.cpp @@ -53,6 +53,7 @@ #include #include "qlabel_p.h" #include "private/qstylesheetstyle_p.h" +#include QT_BEGIN_NAMESPACE @@ -661,7 +662,9 @@ QSize QLabelPrivate::sizeForWidth(int w) const } else { control->setTextWidth(-1); } - br = QRect(QPoint(0, 0), control->size().toSize()); + + QSizeF controlSize = control->size(); + br = QRect(QPoint(0, 0), QSize(qCeil(controlSize.width()), qCeil(controlSize.height()))); // restore state control->setTextWidth(oldTextWidth); -- cgit v0.12