当有昂贵的代表时,我在使用 ListView 时遇到了严重的问题。当我滚动列表视图时,它很生涩。
有一次请帮助解决这个问题。
这是我的示例代码
/ LIstview 带有一些昂贵的虚拟委托,我尝试使用加载器来加载委托,然后它有点好,但仍然是生涩的/
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Window 2.2
ApplicationWindow {
visible: true
width: Screen.width
height: Screen.height
ListView {
width: Screen.width
height: Screen.height
model: 500
spacing: 10
highlightMoveVelocity: 50
flickDeceleration: 500
delegate: Loader{
asynchronous: true
sourceComponent: Image {
width: Screen.width
asynchronous: true
height: index %2 === 0 ? 500: 200
source: "file:///home/Downloads/4k.jpg"
///Just for show
Image {
anchors.fill: parent
asynchronous: true
source: "file:///home/Downloads/4k.jpg"
}
Image {
anchors.fill: parent
asynchronous: true
source: "file:///home/Downloads/4k.jpg"
}
Image {
anchors.fill: parent
asynchronous: true
source: "file:///home/Downloads/4k.jpg"
}
Image {
anchors.fill: parent
asynchronous: true
source: "file:///home/Downloads/4k.jpg"
}
Image {
anchors.fill: parent
asynchronous: true
source: "file:///home/Downloads/4k.jpg"
}
Image {
anchors.fill: parent
asynchronous: true
source: "file:///home/Downloads/4k.jpg"
}
Image {
anchors.fill: parent
asynchronous: true
source: "file:///home/Downloads/4k.jpg"
}
}
}
}
}