diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2012-03-26 16:04:52 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-26 09:25:32 +0200 |
commit | 2532c475d16b7b2252f44ab1fe858d17262d7fc1 (patch) | |
tree | 149fd8bc73f0576e7d6e27e7c55fb4cecee24b78 /src | |
parent | 68ac4c57c46f72b4db16cf02ba67953c9cf4bdc4 (diff) |
Fix horizontal alignment bug with rich text
Task-number: QTBUG-21473
Change-Id: I3542d7fb49ec1ea370709c799167ec01cf5ed19c
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquicktext.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index d7303352c5..e1a28a466a 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -402,7 +402,7 @@ void QQuickTextPrivate::updateSize() if (text.isEmpty()) { qreal fontHeight = fm.height(); q->setImplicitSize(0, fontHeight); - layedOutTextRect = QRect(0, 0, 0, fontHeight); + layedOutTextRect = QRectF(0, 0, 0, fontHeight); emit q->contentSizeChanged(); updateType = UpdatePaintNode; q->update(); @@ -2001,7 +2001,20 @@ QRectF QQuickText::boundingRect() const // Could include font max left/right bearings to either side of rectangle. - int h = height(); + qreal w = width(); + switch (d->hAlign) { + case AlignLeft: + case AlignJustify: + break; + case AlignRight: + rect.moveLeft(w - rect.width()); + break; + case AlignHCenter: + rect.moveLeft((w - rect.width()) / 2); + break; + } + + qreal h = height(); switch (d->vAlign) { case AlignTop: break; |