Binding Text width to implicitWidth can result in incorrect layout
authorMartin Jones <martin.jones@jollamobile.com>
Thu, 10 Jul 2014 06:52:48 +0000 (16:52 +1000)
committerMartin Jones <martin.jones@jollamobile.com>
Fri, 11 Jul 2014 04:16:57 +0000 (06:16 +0200)
If the text is not left aligned and the width changes during layout due
to implictWidth changing, the text needs to be laid out again.

Task-number: QTBUG-40161
Change-Id: I1ad679ccdc5595dd749600abe08ed46ac179d7bf
Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
src/quick/items/qquicktext.cpp

index 7a40278..e26ad27 100644 (file)
@@ -940,9 +940,10 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
             maxHeight = q->heightValid() ? q->height() : FLT_MAX;
 
             // If the width of the item has changed and it's possible the result of wrapping,
-            // eliding, or scaling has changed do another layout.
+            // eliding, scaling has changed, or the text is not left aligned do another layout.
             if ((lineWidth < qMin(oldWidth, naturalWidth) || (widthExceeded && lineWidth > oldWidth))
-                    && (singlelineElide || multilineElide || canWrap || horizontalFit)) {
+                    && (singlelineElide || multilineElide || canWrap || horizontalFit
+                        || q->effectiveHAlign() != QQuickText::AlignLeft)) {
                 widthExceeded = false;
                 heightExceeded = false;
                 continue;