Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] QDeclarativeImageProvider: how to force reload an Image element ?
QtWS25 Last Chance

[Solved] QDeclarativeImageProvider: how to force reload an Image element ?

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    suraj.pavaskar
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • kkoehneK Offline
      kkoehneK Offline
      kkoehne
      Moderators
      wrote on last edited by
      #2

      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?

      Director R&D, The Qt Company

      1 Reply Last reply
      0
      • S Offline
        S Offline
        suraj.pavaskar
        wrote on last edited by
        #3

        yeah tried that, its working for me, thanks for the help!

        1 Reply Last reply
        0
        • E Offline
          E Offline
          emmanueliarussi
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved