Listview dynamic item's scroll problem.
-
Hi.
I coded Listview can show dynamic item using Loader.
It works fine but when adding ScrollView I found one problem.
The scroll moves up and down like "this video":http://www.youtube.com/watch?v=7ohx1hNIChA.
I guess that the problem is occurred by wrong calculated item height.
How can I resolve this problem?Thank you.
Sample qml
@import QtQuick 2.0
import QtQuick.Controls 1.1Rectangle {
width: 360
height: 360ListModel { id: listModel Component.onCompleted: { for(var i = 0; i < 1000; ++i) { append({"contents": qsTr("Sample text"), "type": i % 2}); } } } ScrollView { anchors.fill: parent ListView { id: listView anchors.fill: parent model: listModel delegate: itemDelegate } } Component { id: itemDelegate Item { width: listView.width height: component.height Component { id: txtComponent Item { width: listView.width height: txt.height Text { id: txt font.pixelSize: 15 text: contents } } } Component { id: imgComponent Item { width: listView.width height: img.height Image { id: img source: "http://qt-project.org/images/qt13a/Qt-logo.png" } } } Loader { id: component sourceComponent: type == 0 ? txtComponent : imgComponent } } }
}
@