diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2012-05-03 15:00:33 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-03 08:05:33 +0200 |
commit | f50c0af7532247b3a9c38244ec297da97a8e31ab (patch) | |
tree | 263c6746f8b607b890c3ee2af8dd9288efe660f1 /src/quick | |
parent | bf817782e6dfeb8455febe3e481bcdb4c383ed05 (diff) |
Fix alignment bug in QQuickText with multi-line text and implicit width
If the horizontal alignment is not left and the width of the text is not
known during the first pass, we need to relayout once we know the
maximum line width.
Task-number: QTBUG-18617
Change-Id: I0cad100946beda151034067e23439185684de144
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquicktext.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 4d39f0baad..104a6ab67c 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -916,9 +916,13 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth, qreal *cons && (q->heightValid() || (maximumLineCountValid && canWrap)); const qreal oldWidth = lineWidth; - lineWidth = q->widthValid() && q->width() > 0 ? q->width() : FLT_MAX; + lineWidth = q->widthValid() && q->width() > 0 ? q->width() : *naturalWidth; if (lineWidth != oldWidth && (singlelineElide || multilineElide || canWrap || horizontalFit)) continue; + // If the horizontal alignment is not left and the width was not valid we need to relayout + // now that we know the maximum line width. + if (!q->widthValid() && maxLineCount > 1 && q->effectiveHAlign() != QQuickText::AlignLeft) + continue; } // If the next needs to be elided and there's an abbreviated string available |