我已經使用model-view-delegate範例實現了一個簡單的QML應用程序。在我的申請中,我使用highlight
屬性來強調我的ListView
當前選定的項目。選擇工作正常,但是當我點擊遠處的項目時,突出顯示的移動速度非常緩慢。Listview突出顯示移動非常緩慢
請看下面的例子:
import QtQuick 2.5
ApplicationWindow {
width: 500
height: 400
title: qsTr("List test")
visible: true
ListView {
id: view
anchors.fill: parent
model: 20
delegate: Rectangle {
border.color: "steelblue"
color: Qt.lighter(border.color)
width: ListView.view.width
height: 20
Text { anchors.centerIn: parent; z: 2; text: index + 1 }
MouseArea {
anchors.fill: parent
onClicked: view.currentIndex = index
}
}
highlight: Rectangle {
border.color: "yellow"
border.width: 3
color: "transparent"
height: 20
width: ListView.view.width
z: Infinity
}
}
}
如果你選擇的最後一個元素,突出顯示了移動所有其他物品抵達選擇一個之前。這不是我期望的行爲。我如何才能將突出顯示直接移到最後?