Window {
id: root
visible: true
width: 500
height: 500
color: "#535353"
Rectangle{
id: dst
//(0,0)
}
ListView{
id: view
anchors.fill: parent
anchors.margins: 100
model: 15
spacing: 10
clip: true
delegate: Rectangle{
width: parent.width
height: 50
//产生随机颜色
color: Qt.rgba(Math.random(),Math.random(),Math.random())
Text {
anchors.centerIn: parent
text: index
}
MouseArea{
id: msa
anchors.fill: parent
onClicked: {
//相对于dst(0,0)点的位置坐标
var pos = dst.mapFromItem(msa,mouse.x, mouse.y);
console.log(pos.x,pos.y)
}
}
}
}
// 滚动条 风格样式以效果图未注
Rectangle {