如果你有一个简单的委托来实现(和你在QML工作),你可以真的使用ListView
来完成工作。
这是一个独立的布局原型。通过Image
更改Rectangle
。当模型给出一个奇数或偶数时,您会发现颜色会有所不同。你可以用相同的方式改变Component
的加载方式,source
的Image
,无论你想象什么。
import QtQuick 2.0
Rectangle {
width: 360
height: 200
ListView {
anchors.fill: parent
model: 3
delegate: Rectangle {
id: rect
width: parent.width
height: 60
property bool selected: false
color: selected ? "darkblue" : "transparent"
Rectangle {
id: bubbleIcon
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
width: 40
height: 40
color: "lightblue"
}
Text {
id: chatName
anchors.left: bubbleIcon.right
anchors.leftMargin: 10
height: parent.height
verticalAlignment: Text.AlignVCenter
text: "chat" + modelData
}
Rectangle {
id: notificationIcon
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
width: 40
height: 40
//just an dummy example to show how to change representation base
//expression binding
color: (modelData % 2 === 0) ? "lightGreen" : "red"
}
MouseArea {
anchors.fill: parent
onClicked: {
selected = ! selected;
}
}
}
}
}
来源
2013-12-12 10:15:54
jbh
任何想法,如果有一个例子在那里我可以开始?真的觉得在这一点上输了 – user3082584