diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 934451e825ca22632e16379662d66b4f6f8e911b..917eaeadd8d5b6c76f6fdc48c976f39f8f257261 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -527,10 +527,13 @@ void QQuickTextPrivate::updateSize() } if (internalWidthUpdate) return; + + extra->doc->setPageSize(QSizeF()); if (q->widthValid() && (wrapMode != QQuickText::NoWrap || extra->doc->idealWidth() < q->width())) extra->doc->setTextWidth(q->width()); else extra->doc->setTextWidth(extra->doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) + widthExceeded = extra->doc->textWidth() < extra->doc->idealWidth(); QSizeF dsize = extra->doc->size(); layedOutTextRect = QRectF(QPointF(0,0), dsize); diff --git a/tests/manual/scenegraph_lancelot/data/text/text_html_center_tag.qml b/tests/manual/scenegraph_lancelot/data/text/text_html_center_tag.qml new file mode 100644 index 0000000000000000000000000000000000000000..86b528f0a4cd8a5df5fe4281eb0329f51995275b --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_html_center_tag.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: implicitSizedText + textFormat: Text.RichText + text: "<center>Implicit size<br>----- Second line -----</center>" + anchors.centerIn: parent + color: "white" + + Rectangle { + anchors.fill: parent + z: -1 + color: "blue" + } + } + Text { + textFormat: Text.RichText + text: "<center>Explicit size<br>----- Second line -----</center>" + anchors.top: implicitSizedText.bottom + anchors.topMargin: 10 + anchors.horizontalCenter: parent.horizontalCenter + width: 300 + color: "white" + + Rectangle { + anchors.fill: parent + z: -1 + color: "blue" + } + } +}