summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qlabel.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-25 09:32:49 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-25 09:44:18 (GMT)
commit8f601bf85748ca62344c5dbaef2f3dd941a16466 (patch)
treedb8007c7c49280f91cffa419c595795d26d7832a /src/gui/widgets/qlabel.cpp
parent76267b3608836e1cc46171921caf725cfbd2ecf7 (diff)
downloadQt-8f601bf85748ca62344c5dbaef2f3dd941a16466.zip
Qt-8f601bf85748ca62344c5dbaef2f3dd941a16466.tar.gz
Qt-8f601bf85748ca62344c5dbaef2f3dd941a16466.tar.bz2
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
Diffstat (limited to 'src/gui/widgets/qlabel.cpp')
-rw-r--r--src/gui/widgets/qlabel.cpp5
1 files changed, 4 insertions, 1 deletions
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 <qurl.h>
#include "qlabel_p.h"
#include "private/qstylesheetstyle_p.h"
+#include <qmath.h>
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);