Monday, July 29, 2013

qml example: ListView

qml example: ListView
qml example: ListView

import QtQuick 2.0
import QtWebKit 3.0

Rectangle {
    width: 300
    height: 360

    ListView{
        id: myListView
        width: parent.width
        height: 100
        highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
        focus: true
        model: ["Sunday", "Monday", "Tuesday", "Wednesday",
            "Thursday", "Friday", "Saturday"]
        delegate: Text {text: model.modelData}
        onCurrentItemChanged: myText.text = currentItem.text
    }

    Text {
        id: myText
        anchors.centerIn: parent
    }
}


- This example haven't handle mouse click, you can select items in ListView by UP/DOWN in keyboard. To detect mouse click on ListView, refer to next example of Detect mouse click on ListView.