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. After unregisterResource , why still can use the resource
QtWS25 Last Chance

After unregisterResource , why still can use the resource

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 2.6k 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.
  • H Offline
    H Offline
    hoozi
    wrote on last edited by
    #1

    hi,

    in my case , I want to dinamic Switch the resource.

    so i have two rcc files, they have picture with same alias, like this

    A.rcc
    @
    <RCC>
    <qresource prefix="/">
    <file alias="cover">a.png</file>
    </qresource>
    </RCC>
    @

    B.rcc
    @
    <RCC>
    <qresource prefix="/">
    <file alias="cover">b.png</file>
    </qresource>
    </RCC>
    @

    I first registerResource A.rcc , used a.png

    then unregisterResource A.rcc

    then,
    @
    Image { id: ttt }
    ...
    ttt.source="qrc:/cover";
    @
    it works, used a.png . why???

    then,
    registerResource B.rcc
    still used a.png. why???

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      Is the image element created after the resource file is changed? Or is it created before?

      If the Image element is persistent through the changing of the resource file, try briefly setting ttt.source="" and then resetting ttt.source="qrc:/cover" again. Does it then reload the proper image?

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hoozi
        wrote on last edited by
        #3

        [quote author="mlong" date="1313012387"]Is the image element created after the resource file is changed? Or is it created before?

        If the Image element is persistent through the changing of the resource file, try briefly setting ttt.source="" and then resetting ttt.source="qrc:/cover" again. Does it then reload the proper image? [/quote]

        the image element created after the resource file is changed

        1 Reply Last reply
        0
        • L Offline
          L Offline
          loladiro
          wrote on last edited by
          #4

          A resource file can only be unloaded if it's not being used. Are you sure you're not using it elsewhere?

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hoozi
            wrote on last edited by
            #5

            I can Detailed description Process :

            1. registerResource A.rcc

            2. createQmlObject a Image_A created , used a.png in A.rcc

            3. then, destroy Image_A and unregisterResource A.rcc

            4. Next process, is Confusing. a new created Image_B can set source = "qrc:/cover" , it works used a.png

            5. then I registerResource B.rcc . a new created Image_C set source = "qrc:/cover" , it works still used a.png . why?

            btw, I write a plugin that can call registerResource and unregisterResource in QML.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mbrasser
              wrote on last edited by
              #6

              Hi,

              QML does a lot of caching behind the scenes, and images are one of the things that are cached. From your description it sounds like the cached image is what is continually being used, regardless of changing the underlying resource file.

              QtQuick 1.1 (not yet released, but available as the HEAD of 4.7, or with the recent 4.8 pre-releases) adds a cache property to Image that should allow you to turn off this caching, which might solve your problem.

              Regards,
              Michael

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hoozi
                wrote on last edited by
                #7

                Thanks for Details answers

                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