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. How to clear Image cache?
Forum Updated to NodeBB v4.3 + New Features

How to clear Image cache?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 3 Posters 1.5k 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
    senmx
    wrote on last edited by senmx
    #1
        Image {
            id: img
            anchors.fill: parent
            smooth: true
            source: "file:///Volumes/D/x.png"
            fillMode: Image.PreserveAspectFit
            MouseArea {
                anchors.fill: parent
                onClicked: {
                    if(img.cache) {
                        img.cache = false;
                    } else {
                        img.cache = true;
                    }
                }
            }
        }
    

    How to clear Image cache?

    KroMignonK 1 Reply Last reply
    0
    • S senmx
          Image {
              id: img
              anchors.fill: parent
              smooth: true
              source: "file:///Volumes/D/x.png"
              fillMode: Image.PreserveAspectFit
              MouseArea {
                  anchors.fill: parent
                  onClicked: {
                      if(img.cache) {
                          img.cache = false;
                      } else {
                          img.cache = true;
                      }
                  }
              }
          }
      

      How to clear Image cache?

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by
      #2

      @senmx said in How to clear Image cache?:

      How to clear Image cache?

      I don't think that clearing image cache is what you want.
      Can you please explain what you want to do and why you think you have to clear this cache?

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      S 1 Reply Last reply
      0
      • KroMignonK KroMignon

        @senmx said in How to clear Image cache?:

        How to clear Image cache?

        I don't think that clearing image cache is what you want.
        Can you please explain what you want to do and why you think you have to clear this cache?

        S Offline
        S Offline
        senmx
        wrote on last edited by
        #3

        @KroMignon Thanks, for the time being, do not enable the cache to solve the problem. My needs: "After the picture is modified, the display must be updated."

        eyllanescE KroMignonK 2 Replies Last reply
        0
        • S senmx

          @KroMignon Thanks, for the time being, do not enable the cache to solve the problem. My needs: "After the picture is modified, the display must be updated."

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by eyllanesc
          #4

          @senmx So you want that after the .png file is modified then you want the image to be updated. That cannot be done with QML. You have to use QFileSystemWatcher to monitor the file and then reload the image

          If you want to reload the image when pressed then you can do the following:

          onClicked: {
              img.source = ""
              img.source = "file:///Volumes/D/x.png"
          }

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          S 1 Reply Last reply
          2
          • S senmx

            @KroMignon Thanks, for the time being, do not enable the cache to solve the problem. My needs: "After the picture is modified, the display must be updated."

            KroMignonK Offline
            KroMignonK Offline
            KroMignon
            wrote on last edited by
            #5

            @senmx said in How to clear Image cache?:

            Thanks, for the time being, do not enable the cache to solve the problem. My needs: "After the picture is modified, the display must be updated."

            To force Image reload, you have to change Image.source property.
            So the easiest way is to follow @eyllanesc code example ;)

            Please, always try to give the main problem you try to solve. Sometimes, when trying to solve a problem, you are on the wrong way. If you ask for the main issue, you will get the right answer to solve it :)

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            1 Reply Last reply
            0
            • eyllanescE eyllanesc

              @senmx So you want that after the .png file is modified then you want the image to be updated. That cannot be done with QML. You have to use QFileSystemWatcher to monitor the file and then reload the image

              If you want to reload the image when pressed then you can do the following:

              onClicked: {
                  img.source = ""
                  img.source = "file:///Volumes/D/x.png"
              }
              S Offline
              S Offline
              senmx
              wrote on last edited by senmx
              #6

              @eyllanesc @KroMignon Thks.

              onClicked: {
                  img.cache = false;
                  img.source = ""
                  img.source = "file:///Volumes/D/x.png"
              }
              

              In this way, the update must first set "cache=false" to work. But if set "cahce=true" after the update, the image will return to the old one.

              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