小さなディスプレイに大きなリストを表示したい。ListView の問題は、フリック可能な水平方向または垂直方向の向きを設定する必要があることです。
私が試したのは:
- ListView を Flickable に挿入し、Flickable を水平スクロール用に、ビューを垂直スクロール用に設定しましたが、同時に両側にフリックできません。
- ListView の flickableDirection プロパティを Flickable.HorizontalAndVerticalFlick に設定しようとしましたが、うまくいきませんでした。
簡単な例を次に示します。
import QtQuick 2.2
import QtQuick.Window 2.1
Window {
visible: true
width: 360
height: 360
ListModel {
id: fruitModel
ListElement {
name: "Apple"
cost: 2.45
}
ListElement {
name: "Orange"
cost: 3.25
}
ListElement {
name: "Banana"
cost: 1.95
}
}
ListView {
anchors.fill: parent
model: fruitModel
delegate: Rectangle {
id: delegateRect
height: 150
width: 545
border.color: "steelblue"
border.width: 1
Row {
Text {
id: nameLabel
width: 345
text: name
}
Text {
id: costLabel
width: 200
text: cost
}
}
}
}
}