diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2022-10-28 18:44:07 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2022-11-10 11:52:35 +0100 |
commit | 16ede646c96861a07108499d895c5fc56263f312 (patch) | |
tree | cac5d83905cfd3b866e39b7b27f132a9079aea25 /tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | |
parent | 6a9d50f88dcd7de5933686ca2cabb262ff5d0665 (diff) |
QQuickTableView: emit changes to leftColumn() _after_ it has been updated
An application might listen for e.g the leftColumnChanged signal
and query the position to the delegate items in the new left
column. But for this to work, be sure to layout the items (and
basically finish loading the column) before emitting the
signals, so that leftColumn(), rightColumn(), topRow() and
bottomRow() return the correct values.
Change-Id: I0e64bd2b240b0dac03120a944815ee2e5e43a6a0
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.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index 099895e296..783fa4a265 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -186,6 +186,7 @@ private slots: void itemAtCell(); void leftRightTopBottomProperties_data(); void leftRightTopBottomProperties(); + void leftRightTopBottomUpdatedBeforeSignalEmission(); void checkContentSize_data(); void checkContentSize(); void checkSelectionModelWithRequiredSelectedProperty_data(); @@ -3987,6 +3988,33 @@ void tst_QQuickTableView::leftRightTopBottomProperties() QCOMPARE(bottomSpy.size(), expectedSignalCount.bottom()); } +void tst_QQuickTableView::leftRightTopBottomUpdatedBeforeSignalEmission() +{ + // Check that leftColumn, rightColumn, topRow and bottomRow are + // actually updated before the changed signals are emitted. + LOAD_TABLEVIEW("plaintableview.qml"); + auto model = TestModelAsVariant(100, 100); + tableView->setModel(model); + + WAIT_UNTIL_POLISHED; + + connect(tableView, &QQuickTableView::leftColumnChanged, [=]{ + QCOMPARE(tableView->leftColumn(), 1); + }); + connect(tableView, &QQuickTableView::rightColumnChanged, [=]{ + QCOMPARE(tableView->rightColumn(), 6); + }); + connect(tableView, &QQuickTableView::topRowChanged, [=]{ + QCOMPARE(tableView->topRow(), 1); + }); + connect(tableView, &QQuickTableView::bottomRowChanged, [=]{ + QCOMPARE(tableView->bottomRow(), 8); + }); + + tableView->setContentX(100); + tableView->setContentY(50); +} + void tst_QQuickTableView::checkContentSize_data() { QTest::addColumn<int>("rowCount"); |