aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/items/qquickitemview.cpp3
-rw-r--r--tests/auto/qmltest/listview/tst_listview.qml21
2 files changed, 23 insertions, 1 deletions
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 188b347a20..aff03b7539 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -1052,7 +1052,8 @@ QQuickItem *QQuickItemView::itemAt(qreal x, qreal y) const
void QQuickItemView::forceLayout()
{
Q_D(QQuickItemView);
- d->applyPendingChanges();
+ if (isComponentComplete() && (d->currentChanges.hasPendingChanges() || d->forceLayout))
+ d->layout();
}
void QQuickItemViewPrivate::applyPendingChanges()
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);
+ }
}
}