diff options
author | Tim Jenssen <tim.jenssen@qt.io> | 2017-09-12 17:12:18 +0200 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2017-09-14 05:20:20 +0000 |
commit | 3604cae410f29597c97ba73df6d31a9b54e6d30d (patch) | |
tree | 06fa1ec60a5872f1b799023b1a81ebb1fa9d652d | |
parent | bb02a577f0fbf3bd2a273129e6cb57cfc9a338c8 (diff) |
QQuickTextEdit: call implicitWidth() even if requireImplicitWidth is true
Before once requireImplicitWidth was set to true by requesting
the implicit width, the implicit (and width) was never updated again, even
if the text was updated/changed.
Adding also a test
Task-number: QTBUG-63153
Change-Id: Ie3bac4baeb14c2e69acc43d11a351ac91d5400da
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r-- | src/quick/items/qquicktextedit.cpp | 2 | ||||
-rw-r--r-- | tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 61d610520f..3714af2bc3 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -2480,7 +2480,7 @@ void QQuickTextEdit::updateSize() if (d->isImplicitResizeEnabled()) { // ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed. - if (!widthValid() && !d->requireImplicitWidth) + if (!widthValid()) setImplicitSize(newWidth + leftPadding() + rightPadding(), newHeight + topPadding() + bottomPadding()); else setImplicitHeight(newHeight + topPadding() + bottomPadding()); diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index ac57a05176..d58fc6c389 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -158,6 +158,7 @@ private slots: #endif void implicitSize_data(); void implicitSize(); + void implicitSize_QTBUG_63153(); void contentSize(); void boundingRect(); void clipRect(); @@ -3388,6 +3389,18 @@ void tst_qquicktextedit::implicitSize() QCOMPARE(textObject->height(), textObject->implicitHeight()); } +void tst_qquicktextedit::implicitSize_QTBUG_63153() +{ + QString componentStr = "import QtQuick 2.0\nTextEdit { }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create()); + textObject->setText("short"); + qreal shortImplicitWidth = textObject->implicitWidth(); + textObject->setText("in contrast to short this is long"); + QVERIFY2(shortImplicitWidth < textObject->implicitWidth(), qPrintable(QString("%1 < %2").arg(textObject->implicitWidth()).arg(shortImplicitWidth))); +} + void tst_qquicktextedit::contentSize() { QString componentStr = "import QtQuick 2.0\nTextEdit { width: 75; height: 16; font.pixelSize: 10 }"; |