diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-06-01 12:36:47 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-04 13:03:13 +0000 |
commit | af46cc19937dd8d33538e62ad5ebfed8e958a8f5 (patch) | |
tree | f369703facac3d2b1a0fc599c20a60c0a0a5222f /tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | |
parent | 07946c110b3d6fde378dc2a6e821b318c4a68536 (diff) |
TableView: fall back to use implicit size for delegate items
Rather than forcing users to set TableView.cellWidth/cellHeight (and
therefore also force them to create an attached object for every
cell), we now also accept setting implict size as a fall back.
Change-Id: I4c4c4d23fe7fc193581728d3878cf2c7e40c0745
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview/tst_qquicktableview.cpp')
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index 16b3acab99..c12e9a9432 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -86,6 +86,7 @@ private slots: void emptyModel_data(); void emptyModel(); void checkZeroSizedDelegate(); + void checkImplicitSizeDelegate(); void noDelegate(); void countDelegateItems_data(); void countDelegateItems(); @@ -209,6 +210,28 @@ void tst_QQuickTableView::checkZeroSizedDelegate() } } +void tst_QQuickTableView::checkImplicitSizeDelegate() +{ + // Check that we can set the size of delegate items using + // implicit width/height, instead of forcing the user to + // create an attached object by using TableView.cellWidth/Height. + LOAD_TABLEVIEW("tableviewimplicitsize.qml"); + + auto model = TestModelAsVariant(100, 100); + tableView->setModel(model); + + WAIT_UNTIL_POLISHED; + + auto items = tableViewPrivate->loadedItems; + QVERIFY(!items.isEmpty()); + + for (auto fxItem : tableViewPrivate->loadedItems) { + auto item = fxItem->item; + QCOMPARE(item->width(), 90); + QCOMPARE(item->height(), 60); + } +} + void tst_QQuickTableView::noDelegate() { // Check that you can skip setting a delegate without |