我创建了一个列表视图,其中包含图像,当向下滚动时会自动请求新项目。我正在使用Image组件来显示来自url源的图像。问题在于图像在加载后不会缓存在内存中。当我向下滚动时,我可以看到它们,但当我回来时,我必须等待它们再次加载。有没有办法来解决这个问题?图像组件具有属性缓存但它没有任何改进。我知道在Android中,这是以完全相同的方式完成的,并且图像一旦下载就保存在内存中。 这里是一个示例代码:qml listview图像缓存不能按预期的那样工作
ApplicationWindow {
visible: true
width: 800
height: 600
id: rootId
property url fullImageUrl
property string tag : "windsurfing"
XmlListModel{
id : modelId
namespaceDeclarations: "declare namespace media = 'http://search.yahoo.com/mrss/';"
source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2&tags="+tag
query: "//item[title and media:thumbnail and media:content]"
XmlRole{name:"fullImage"; query:"media:content/@url/string()" }
}
TextField{
id : userValueId
font.pointSize: 14
width: parent.width
height : implicitHeight
placeholderText: "Enter a Flickr Tag"
onEditingFinished: tag = text
}
ListView{
id : listViewId
anchors.fill: parent
anchors.topMargin: userValueId.height + 10
Layout.minimumWidth: 400
Layout.maximumWidth: parent.width - 50
model: modelId
delegate: delegateId
}
Component{
id: delegateId
Rectangle{
id :itemId
height : 300
width : 500
Image{
id : imageId
source : fullImage
anchors.fill: parent
fillMode: Image.Stretch
cache: true
}
}
}
}