diff options
author | Jens Bache-Wiig <jens.bache-wiig@digia.com> | 2014-04-14 12:44:34 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-15 11:15:56 +0200 |
commit | f580f4ce858a332e62948c1c5372995e9a576452 (patch) | |
tree | f5b633ce0a4f68c56f762e5d80075434e96e1f20 /tests | |
parent | 53fca456b2d5c4d290592846c0a14242ac218e1d (diff) | |
download | qtquickcontrols-f580f4ce858a332e62948c1c5372995e9a576452.tar.gz |
Ensure that styleData.row is initialized in delegates
While we specifically documented that you should not depend on
the value being correct in onCompleted for 5.3, it is not
optimal that the initial value is consistently set to 0 and later
changed to it's appropriate value. This patch ensures that delegates
are not instantiated until after the model model and row values
have been fully initialized.
Task-number: QTBUG-38307
Change-Id: Ib3300539a0283c997ab8b808fb229d3f22ed6324
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_tableview.qml | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml index a9f07a8b..c99d2dcd 100644 --- a/tests/auto/controls/data/tst_tableview.qml +++ b/tests/auto/controls/data/tst_tableview.qml @@ -385,6 +385,24 @@ TestCase { verify(table.selection.contains(8)) } + function test_initializedStyleData() { + var table = Qt.createQmlObject('import QtQuick.Controls 1.2; \ + import QtQuick 2.2; \ + TableView { \ + model: 3; \ + TableViewColumn{} \ + property var items: []; \ + property var rows: []; \ + itemDelegate: Item{ Component.onCompleted: { items.push(styleData.row) } } \ + rowDelegate: Item{ Component.onCompleted: { if (styleData.row !== undefined) rows.push(styleData.row) } } \ + }' + , testCase, '') + waitForRendering(table) + compare(table.items, [0, 1, 2]); + compare(table.rows, [0, 1, 2]); + } + + function test_usingcppqobjectmodel() { var component = Qt.createComponent("tableview/table1_qobjectmodel.qml") |