diff options
author | Dominik Holland <dominik.holland@qt.io> | 2022-09-14 15:39:08 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@qt.io> | 2022-09-20 07:10:04 +0000 |
commit | 3aca22d5f5fffb4a627a18aff445de565177b730 (patch) | |
tree | 94dc98db026a61173bd5aba443409bdcea50aee3 /tests/auto/quick | |
parent | 3ec62d9949012a4a57be1a6119298c962a700a3f (diff) |
Text: Re-layout the text when a alignment is set and the height grows
When the top alignment (default) is used, a growing height can be
ignored in some situations and no re-layout is needed. But once
the alignment has been changed, the re-layout needs to happen, as
otherwise not all anchors are updated correctly.
Fixes: QTBUG-106594
Change-Id: I9ab9999f49331aadd3bb8247d520288c40b51b21
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
(cherry picked from commit 4933bd6351feec988746af647c391c46483f049a)
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r-- | tests/auto/quick/qquicktext/tst_qquicktext.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 35ff634b2e..4bf0e9596c 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -3630,6 +3630,30 @@ void tst_qquicktext::fontSizeMode() myText->setElideMode(QQuickText::ElideNone); QVERIFY(QQuickTest::qWaitForItemPolished(myText)); + + // Growing height needs to update the baselineOffset when AlignBottom is used + // and text is NOT wrapped + myText->setVAlign(QQuickText::AlignBottom); + myText->setFontSizeMode(QQuickText::Fit); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); + + int baselineOffset = myText->baselineOffset(); + myText->setHeight(myText->height() * 2); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); + QVERIFY(myText->baselineOffset() > baselineOffset); + + // Growing height needs to update the baselineOffset when AlignBottom is used + // and the text is wrapped + myText->setVAlign(QQuickText::AlignBottom); + myText->setFontSizeMode(QQuickText::Fit); + myText->setWrapMode(QQuickText::NoWrap); + myText->resetMaximumLineCount(); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); + + baselineOffset = myText->baselineOffset(); + myText->setHeight(myText->height() * 2); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); + QVERIFY(myText->baselineOffset() > baselineOffset); } void tst_qquicktext::fontSizeModeMultiline_data() |