diff options
author | Alexander Volkov <a.volkov@rusbitech.ru> | 2016-10-18 16:35:16 +0300 |
---|---|---|
committer | Alexander Volkov <a.volkov@rusbitech.ru> | 2017-01-12 17:54:52 +0000 |
commit | a4c25c020554527aa9ff9b533afabffef46be131 (patch) | |
tree | 343109f81aa8eec74eba69700a3e842b6551c7e9 /tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp | |
parent | dcec1420ea9d7e90bbd7f37be15d8e61eaf35d23 (diff) |
Add expandingListItems property to QListView
This property allows to change the default behavior in
which list items occupy the entire width of the column.
Setting it to false will reduce their widths to the
minimum values, thus allowing to have intermediate free
space. Then the user will be able to begin selections
by mouse from this space.
[ChangeLog][QtWidgets][QListView] Added expandingListItems property.
Change-Id: I6bd1b147fd0335324310a165104c36f6b0d6ac9f
Task-number: QTBUG-56606
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Diffstat (limited to 'tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp')
-rw-r--r-- | tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 0f1c5723d5..e5e9b87df4 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -150,6 +150,7 @@ private slots: void horizontalScrollingByVerticalWheelEvents(); void taskQTBUG_7232_AllowUserToControlSingleStep(); void taskQTBUG_51086_skippingIndexesInSelectedIndexes(); + void expandingListItems(); }; // Testing get/set functions @@ -2486,5 +2487,28 @@ void tst_QListView::taskQTBUG_51086_skippingIndexesInSelectedIndexes() QVERIFY(!indexes.contains(data.index(8, 0))); } +void tst_QListView::expandingListItems() +{ + auto item1 = new QStandardItem("111"); + auto item2 = new QStandardItem("111111"); + QStandardItemModel model; + model.appendRow(item1); + model.appendRow(item2); + + QListView w; + w.setModel(&model); + w.setWrapping(true); + w.show(); + QVERIFY(QTest::qWaitForWindowExposed(&w)); + + QVERIFY(w.visualRect(item1->index()).width() > 0); + QVERIFY(w.visualRect(item1->index()).width() == w.visualRect(item2->index()).width()); + + w.setExpandingListItems(false); + QApplication::processEvents(); + + QVERIFY(w.visualRect(item1->index()).width() < w.visualRect(item2->index()).width()); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" |