[Solved] QDeclarativeImageProvider: how to force reload an Image element ?
-
I have implemented an image provider class inherited from QDeclarativeImageProvider.
I am using an Image element for accessing an image from this image provider class asynchronously.@
Image {
id: thumbnail
asynchronous: true
source: {
isThumbAvailable ? "image://thumbprovider/" + currentName:
"qrc:/images/default.png";
}onSourceChanged: { console.log("onSourceChanged: " + source); } }
@
I want to force the reload on the same image (same source url) element following some event on UI.
I tried switching source url to trigger the source change, the "onSourceChanged" slot is invoked but "QImage ThumbProvider::requestImage()" method is not invoked at all.But I noticed one peculiar thing here, if the source url is changed after an interval (of around 5 sec) the requestImage() method is invoked. By any chance the images loaded via ImageProvider class are cached ? any way to clear this cache ?
Any help is much appreciated ?
[EDIT: code markup, please wrap in @-Tags, Volker]
-
The easiest way to prevent caching is to change the image URL by appending e.g. a unique "version" number to the URL. Your QDeclarativeImageProvider implementation would just ignore this part. Might work in your case, too?
-
yeah tried that, its working for me, thanks for the help!
-
Hi!
I had the same problem, and your solution worked for me.
I have a ListView showing thumbnails changing from time to time. I'm providing the images using a class inherited from QDeclarativeImageProvider.
BUT when removing items from the list, this trick is not working any more for the items after the one removed. The items above the one removed are reloading their images properly, but not the others.
Any suggestions? Help is appreciated