summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2015-03-30 10:20:07 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-04-04 12:24:44 +0000
commit5aa40e5b00eb8f54157bc1aa01205a8a87e0c661 (patch)
tree3796ef2c1d1c554d93fbdbd73b6d8ef596d7d6a5 /tests
parentddb0628181ba6f2ebeedf7e8f4186861ab63b628 (diff)
QComboBox: also adjust size on model reset, with AdjustToContents
When the size adjust policy is QComboBox::AdjustToContents, the combobox sizeHint was recalculated on dataChanged, rowsInserted, rowsRemoved, and setModel, but not when the model was reset. This led to truncated items in the combobox when models are filled asynchronously. Task-number: QTBUG-5413 Change-Id: I3456c327d680dfffa58d6dcb26c79456c67b2a32 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 97416135db..c409698ec0 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -531,6 +531,23 @@ void tst_QComboBox::sizeAdjustPolicy()
QCOMPARE(testWidget->sizeHint(), content);
testWidget->setMinimumContentsLength(0);
QVERIFY(testWidget->sizeHint().width() < content.width());
+
+ // check AdjustToContents changes when model changes
+ content = testWidget->sizeHint();
+ QStandardItemModel *model = new QStandardItemModel(2, 1, testWidget);
+ testWidget->setModel(model);
+ QVERIFY(testWidget->sizeHint().width() < content.width());
+
+ // check AdjustToContents changes when a row is inserted into the model
+ content = testWidget->sizeHint();
+ QStandardItem *item = new QStandardItem(QStringLiteral("This is an item"));
+ model->appendRow(item);
+ QVERIFY(testWidget->sizeHint().width() > content.width());
+
+ // check AdjustToContents changes when model is reset
+ content = testWidget->sizeHint();
+ model->clear();
+ QVERIFY(testWidget->sizeHint().width() < content.width());
}
void tst_QComboBox::clear()