summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews
diff options
context:
space:
mode:
authorAlexander Volkov <a.volkov@rusbitech.ru>2016-10-18 16:35:16 +0300
committerAlexander Volkov <a.volkov@rusbitech.ru>2018-06-08 12:35:15 +0000
commit649490f359bc7308a0e21f0b38cf9b8a01e7b619 (patch)
tree7335b3d8236424c4c5de2d810bf955a2b30ed0d3 /tests/auto/widgets/itemviews
parent6c566e506b7316b3495fe73b5f7ee4dc8902c9d2 (diff)
Add itemAlignment property to QListView
This property allows to change the default behavior in which list items occupy the entire width of their column. Setting it to Qt::{AlignLeft,AlignRight,AlignHCenter} 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 itemAlignment property. Task-number: QTBUG-56606 Change-Id: Iae55c251379be4e45d0c0d69175ff4388b5785b4 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/widgets/itemviews')
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp24
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 237b950935..8287495dc6 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -149,6 +149,7 @@ private slots:
void taskQTBUG_7232_AllowUserToControlSingleStep();
void taskQTBUG_51086_skippingIndexesInSelectedIndexes();
void taskQTBUG_47694_indexOutOfBoundBatchLayout();
+ void itemAlignment();
};
// Testing get/set functions
@@ -2544,5 +2545,28 @@ void tst_QListView::taskQTBUG_47694_indexOutOfBoundBatchLayout()
view.scrollTo(model.index(batchSize - 1, 0));
}
+void tst_QListView::itemAlignment()
+{
+ 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.setItemAlignment(Qt::AlignLeft);
+ QApplication::processEvents();
+
+ QVERIFY(w.visualRect(item1->index()).width() < w.visualRect(item2->index()).width());
+}
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"