aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals@canonical.com>2016-03-07 13:18:56 +0100
committerAlbert Astals Cid <albert.astals@canonical.com>2016-03-11 13:30:34 +0000
commit201dec50b6f08b740aab9947725f8f5ec36349bb (patch)
tree4b56b6dac0f81afc9f1b6c613c3ba80b05e36bd9 /tests/auto/qmltest
parent644a6a42a45ceb9790df6d6ee1c3ba43c7b9ab10 (diff)
QQuickItemView::forceLayout: Also call layout when d->forceLayout
This way callers of forceLayout get a relayout if the dimension of a delegate that affects the itemview content size has just changed but the itemview content size has not been updated yet. This is useful because sometimes in the QML side you want to do things when the item view delegate size has changed but need the item view content size to be already updated. Change-Id: I846984a841e8e14c84d7a700a7ff736196b60afb Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Diffstat (limited to 'tests/auto/qmltest')
-rw-r--r--tests/auto/qmltest/listview/tst_listview.qml21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qmltest/listview/tst_listview.qml b/tests/auto/qmltest/listview/tst_listview.qml
index 988d30f9a2..75429c43e1 100644
--- a/tests/auto/qmltest/listview/tst_listview.qml
+++ b/tests/auto/qmltest/listview/tst_listview.qml
@@ -51,6 +51,22 @@ Item {
}
ListView {
+ id: singleElementList
+ height: 20
+ width: 50
+ model: 1
+ property real heightForDelegate: 100
+ property real contentHeightOnDelegateResize
+ delegate: Rectangle {
+ height: singleElementList.heightForDelegate
+ onHeightChanged: {
+ singleElementList.forceLayout();
+ singleElementList.contentHeightOnDelegateResize = singleElementList.contentHeight;
+ }
+ }
+ }
+
+ ListView {
id: viewmanyitems
model: manyitems
delegate: Text { text: model.name }
@@ -313,5 +329,10 @@ Item {
compare(listInteractiveCurrentIndexEnforce.currentIndex, 1);
tryCompare(listInteractiveCurrentIndexEnforce, "contentX", listInteractiveCurrentIndexEnforce.width);
}
+
+ function test_forceLayoutForContentHeight() {
+ singleElementList.heightForDelegate = 200;
+ compare(singleElementList.contentHeightOnDelegateResize, 200);
+ }
}
}