Tôi muốn làm một ListView ngang hoạt động như một đại biểu cho một ListView veritcal, tôi đã viết đoạn mã sau:ListView ngang bên dọc listview trong QML
import Qt 4.7
Item {
id:main
width: 360
height: 640
Component{
id:myDelegate
ListView{
id:list2
spacing: 5
width:list.width
height:list.height/3
interactive: true
orientation: ListView.Horizontal
model: ListModel {
ListElement {
name: "Bill Smith"
number: "555 3264"
}
ListElement {
name: "John Brown"
number: "555 8426"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
}
delegate: Text{text:name
width: main.width/3}
focus: true
MouseArea {
anchors.fill: parent
onClicked: {
ListView.list2.currentIndex = ListView.list2.indexAt(mouseX, mouseY)
}
}
}
}
ListView {
id: list
clip: true
spacing: 5
anchors.fill: parent
orientation: ListView.Vertical
model: Model{}
delegate:myDelegate
// highlight: Rectangle {
// width: list.currentItem.width
// color: "lightsteelblue"
// radius: 5
// }
focus: true
MouseArea {
anchors.fill: parent
onClicked: {
list.currentIndex = list.indexAt(mouseX, mouseY)
}
}
}
}
Các listview cuộn dọc cũng nhưng một trong những ngang không cuộn. Bất kỳ trợ giúp nào? Cảm ơn
Đúng là Một giải pháp khác là xóa tiêu điểm: đúng từ danh sách dọc –