QQuickImageProvider force image to be updated. How to?



  • Hi. I have QQuickImageProvider and I need to keep image in sync in QML with source set to this QQuickImageProvider to be updated in case of its source changes.
    How to do this? I ask because QQuickImageProvider does not have any signals or to indicate that source changed.
    What is the benefit of using QQuickImageProvider instead of P_PROPERTY(QImage image... ) which signals about changes?



  • @Kofr if you're using the QQuickImageProvider to load the image, once the onSourceChanged signal (Image class) is triggered the requestImage() function of QQuickImageProvider will be called.

    Kindly refer to the documentation for its benefits.


  • Moderators

    @Kofr said in QQuickImageProvider force image to be updated. How to?:

    What is the benefit of using QQuickImageProvider instead of P_PROPERTY(QImage image... ) which signals about changes?

    the benefits are well described in the class description.

    As the classname says it's supposed to provide images. The images do not necessarily exist. For example you could create pixmaps on the fly specified by url parameters.

    You need to create a separate QObject which keeps track of the images and triggers when you want it to. the image provider is still needed though. But in QML you could request the image url via your custom object which then also registers to trigger updates when it changes for example.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.