Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image element doesn't update when the image content changes with QDeclarativeImageProvider

Tags:

qt

qt-quick

qml

I have a listview element like this :

ListView {
    id: view
    width: 200; height: 250
    model:myModel;
    delegate:
        Text{
            text:  bareJid + ' '+status;
            Image{
                source:image;
            }
        }
}

in the delegate Image element gets its image from a QDeclarativeImageProvider . but when the content of the image changes myModel doesn't update. How can I notice it to reload image when the content of the image has changed. thanks.

like image 977
s4eed Avatar asked Feb 20 '23 15:02

s4eed


1 Answers

The Image item will not attempt to re-fetch the image at all unless the source is changed. Typically this is achieved by appending an id, which you can increment, to the end of the image name and dealing with that in your model and provider. You should also set cache: false since there is no point caching an image that is changing.

Another possibility may be to set cache: false and change the image role first to "", and then back to the actual name, remembering to emit dataChanged after each change. Note that the image must not have previously been loaded with cache: true, or the cached version will be used regardless (this is fixed in QtQuick 2.0).

like image 177
MartinJ Avatar answered Apr 27 '23 11:04

MartinJ