From 79cfc8788d6267eeb263983466ba21758f618dcd Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 12 May 2016 14:56:20 +0200 Subject: Fix incorrectly aligned text whose size depends on its implicit size The if statement in QQuickTextPrivate::setupTextLayout() was missing an OR clause for the case where the line width is neither greater nor less than the old width/natural width, but has actually changed. If that sounds confusing, it's because it is. Basically, the outer layouting loop in that function needs to run twice for this scenario, so that's what this patch makes it do. Change-Id: I13777667eb13506d50f05e9766785a1c2c46125c Task-number: QTBUG-50738 Task-number: QTBUG-50740 Reviewed-by: Liang Qi --- .../data/hAlignWidthDependsOnImplicitWidth.qml | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/auto/quick/qquicktext/data/hAlignWidthDependsOnImplicitWidth.qml (limited to 'tests/auto/quick/qquicktext/data/hAlignWidthDependsOnImplicitWidth.qml') diff --git a/tests/auto/quick/qquicktext/data/hAlignWidthDependsOnImplicitWidth.qml b/tests/auto/quick/qquicktext/data/hAlignWidthDependsOnImplicitWidth.qml new file mode 100644 index 0000000000..4358a58f57 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/hAlignWidthDependsOnImplicitWidth.qml @@ -0,0 +1,25 @@ +import QtQuick 2.6 + +Item { + width: 200 + height: 200 + + property alias text: label.text + property alias horizontalAlignment: label.horizontalAlignment + property alias elide: label.elide + property int extraWidth: 0 + + Rectangle { + border.color: "red" + x: 100 + width: label.implicitWidth + extraWidth + height: label.implicitHeight + + Text { + id: label + anchors.fill: parent + text: 'press me' + horizontalAlignment: Text.AlignHCenter + } + } +} -- cgit v1.2.3