aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-09 09:15:08 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-09 16:20:56 +0000
commit1d6dcee6cc75b65092715acc59d4481a2dfeb5ec (patch)
tree85702162a38b943ef390555a73e63d4e5ebf7e0c /tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
parent82da798499aa8b656e771191332864a703069739 (diff)
QQuickTableView: override contentWidth/Height properties
TableView uses contentWidth/height to report the size of the table (this will e.g make scrollbars written for Flickable work out of the box). This value is continuously calculated, and will change/improve as more columns are loaded into view. At the same time, we want to open up for the possibility that the application can set the content width explicitly, in case it knows what the exact width should be from the start. We therefore override the contentWidth/height properties from QQuickFlickable, to be able to implement this combined behavior. This also lets us lazy build the table if the application needs to know the content size early on. The latter will also fix problems related to querying the content size from Component.onCompleted. Change-Id: Ife7ef551dc46cf15d6940e3c6dff78545a3e4330 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview/tst_qquicktableview.cpp')
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
index 94d3a356fe..b2f4e412f1 100644
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -96,6 +96,7 @@ private slots:
void checkRowHeightProviderInvalidReturnValues();
void checkRowHeightProviderNotCallable();
void checkContentWidthAndHeight();
+ void checkExplicitContentWidthAndHeight();
void noDelegate();
void countDelegateItems_data();
void countDelegateItems();
@@ -481,6 +482,24 @@ void tst_QQuickTableView::checkContentWidthAndHeight()
QCOMPARE(tableView->contentHeight(), expectedFullSize);
}
+void tst_QQuickTableView::checkExplicitContentWidthAndHeight()
+{
+ // Check that you can set a custom contentWidth/Height, and that
+ // TableView doesn't override it while loading more rows and columns.
+ LOAD_TABLEVIEW("contentwidthheight.qml");
+
+ tableView->setContentWidth(1000);
+ tableView->setContentHeight(1000);
+ QCOMPARE(tableView->contentWidth(), 1000);
+ QCOMPARE(tableView->contentHeight(), 1000);
+
+ // Flick somewhere. It should not affect the contentWidth/Height
+ tableView->setContentX(500);
+ tableView->setContentY(500);
+ QCOMPARE(tableView->contentWidth(), 1000);
+ QCOMPARE(tableView->contentHeight(), 1000);
+}
+
void tst_QQuickTableView::noDelegate()
{
// Check that you can skip setting a delegate without