ListView rendering problem
-
Can someone tell me what's wrong with the current implementation?
@import QtQuick 1.1
import com.nokia.meego 1.0Page {
tools: commonTools
property string path: "/"
function add_element(element){
console.log(element.name)
elements.append(element);
}ListModel{ id: elements ListElement{ name: "prova" } ListElement{ name: "gino" } } Flickable{ anchors.fill: parent width: parent.width contentHeight: list.height ListView{ id: list width: parent.width model: elements delegate: Item { signal clicked(string name) width: parent.width height: 100 Label{ id: label anchors.centerIn: parent text: name font: UiConstants.TitleFont } MouseArea{ anchors.fill: parent onClicked: { parent.clicked(name) } } Rectangle{ width: parent.width height: 2 color: "white" anchors.bottom: parent.bottom } } } } Component.onCompleted: { add_element({"name": "test"}) }
}@
When the list is displayed i can see only the first list item
Thank You -
Why did you put the ListView inside the Flickable?
Most probably it would result to unexpected behavior because the mouse events would be caught by the Flickable element not letting you select an element from the list. Also in the ListView you haven't set the height so probably this is why you can see only the first element.So, if you only want to use the ListView remove the Flickable and add the anchors.fill: parent to the ListView.
-
You're right
i did not know that the ListView is already scrollable. I thought it was like a Column.
Thank you again!