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. Can not unloadImage using QML canvas
Qt 6.11 is out! See what's new in the release blog

Can not unloadImage using QML canvas

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 2 Posters 4.1k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    Tân Ngọc Đỗ
    wrote on last edited by
    #1

    Hello all,

    I have a problem with qml canvas. I want to read series of images in hard drive, with each image I load it into qml canvas :
    @
    onImageChanged : {
    canvas.unload(oldUrl);

    canvas.load(newUrl);
    canvas.isImageLoaded(newUrl); //some times false and sometimes true
    }

    onImageLoaded: //request my canvas to paint image was loaded

    @

    I have a problem when showing to fast 2 different images and my canvas can not unload the old image . So my old image is still in canvas buffer .
    I want to finish unload all image in canvas before drawing new one.

    Could you please help me?

    Thank you!

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      After unload can you check if the image is unloaded as you have tested earlier using canvas.isImageLoaded(newUrl) ?

      bq. canvas.isImageLoaded(newUrl); //some times false and sometimes true

      This is because the function loadImage(url image) asynchronously loads the image.

      157

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tân Ngọc Đỗ
        wrote on last edited by
        #3

        Thanks for your answer,

        Maybe, canvas.unloadImage is also asynchronous. I hope we can have a signal unloadedImage to check if image is unloaded or not !!!!!!

        I have to use a work-around solution like that:

        @
        canvas.load(newUrl);
        if( canvas.isImageLoaded(newUrl) )
        // draw newUrl image to canvas.

        @

        Other solutions is welcome

        Thank you

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Are you sure that unloadImage is taking time ?
          What does canvas.isImageLoaded(url) show after you unloadImage ?

          157

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Tân Ngọc Đỗ
            wrote on last edited by
            #5

            Hello,

            I want to check that if one image is still on canvas memory I will draw that Image , if not I will draw at OnImageLoaded.

            I doubt canvas.unloadImage is not synchronous because :
            @
            canvas.unloadImage(url);
            canvas.isImageLoaed(url) //some time It is true and some time it is false
            @

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              According to the source "here":https://qt.gitorious.org/qt/qtdeclarative/source/05f767f777d92f41cec1d8bb9a512b1f2e40ef5f:src/quick/items/context2d/qquickcanvasitem.cpp#L1008-1011 it seems to be synchronous unlike the loadImage function above.

              157

              1 Reply Last reply
              0
              • T Offline
                T Offline
                Tân Ngọc Đỗ
                wrote on last edited by
                #7

                One point to bookmark . Though, I have a work-around solution but I will investigate more.

                Thank you!

                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