Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Updating multiple QImages on QML::Image view displays only the last one
Qt 6.11 is out! See what's new in the release blog

Updating multiple QImages on QML::Image view displays only the last one

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 2 Posters 2.2k 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.
  • Roby BrundleR Offline
    Roby BrundleR Offline
    Roby Brundle
    wrote on last edited by
    #1

    I have Image qml component to display QImages. Following is the QML code for it.

    Code:

    Item {
    
        Image {
           id: my_qimage_viewer
           anchors.fill: parent
        }
    
        Connections {
            target: qimage_selector_cpp_backend
            onQImageDisplayRequested: {
                my_qimage_viewer.source = next_qimage_source
                console.log("New qimage sent for display is : " + my_qimage_viewer.source)
            }
        }
    
    }
    

    What is working:
    I have a C++ class using QQuickImageProvider to supply QImages with different IDs every time.

    This technique basically works if I update single QImages on selection of some button by user. I can generate a QImage on the fly & update it on my_qimage_viewer. Also able to display multiple different images on demand from user. This proves that my technique using QQuickImageProvider is basically working.

    What is not working
    But, here is where the problem arises. when I send many QImages subsequently, like 50-60 of them all in a for loop, then it does not display all but only displays the last one sent for update !

    My objective here is to try play 50-60 QImages with some millis gap in between to make them appear like a video/animation. Is it that the Image component is not made for such kind of use? Or is it that I am doing some mistake?

    Question:
    May be I should wait for each QImage to be display complete before updating the next? How can I do that if that is whats missing?

    Is there an example of an app using Image to display multiple QImages making it appear like a video or animation?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You for loop will block the event loop so it's not really a good idea. What about just using a QTimer with the adequate speed to trigger the update ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Roby BrundleR 1 Reply Last reply
      3
      • SGaistS SGaist

        Hi,

        You for loop will block the event loop so it's not really a good idea. What about just using a QTimer with the adequate speed to trigger the update ?

        Roby BrundleR Offline
        Roby BrundleR Offline
        Roby Brundle
        wrote on last edited by Roby Brundle
        #3

        @SGaist thanks for your attention on this.

        May be I should use an thread to run the for loop ? Then update the QImage based on some queued signal or slot ? Is there a standard example of updating multiple QImages on a QML::Image component ?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Something is not clear: do you have multiple Image object using the same provider that you want to update or do you have one Image component that you want too use as some sort of video widget ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          Roby BrundleR 1 Reply Last reply
          0
          • SGaistS SGaist

            Something is not clear: do you have multiple Image object using the same provider that you want to update or do you have one Image component that you want too use as some sort of video widget ?

            Roby BrundleR Offline
            Roby BrundleR Offline
            Roby Brundle
            wrote on last edited by
            #5

            @SGaist I have only one Image component which I want to update with QImages consecutively. Yes basically use it like a VideoWidget. But, I figured out the reason of the issue. the for loop was blocking the main event loop as you said :-) thanks

            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