Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Streaming QImage objects from C++ to QML context with QDeclarativeImageProvider

    QML and Qt Quick
    2
    4
    3514
    Loading More Posts
    • 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
      tottv last edited by

      Hi

      I am currently working on an application where i need to stream a series of images from C++ into QML context, to display some sort of real-time animation. The solution I have implemented so far is to use a QDeclarativeImageProvider and 'force' the QML UI to reload the source QImage from the provider by giving a unique index to the URL each time the source is set (as described on this "post here,":http://qt-project.org/forums/viewthread/5726), here is some sample code of the QML connection to the c++ image streamer..

      @ Connections{
      target: imageSender

          onNewImage: {
      
                theImageDisplayed.source = "image://provider/current" + script.x
      
          }
      }@
      

      This works ok, but given that the QDeclarativeImageProvider returns the QImages by value it has one main disadvantage, and that is that IF the images are big, they do not load on time because the data is copied and the 'animation' does not appear fluid.

      My question is.. am I doing it right? or is there a way to stream images from C++ to QML by reference? any other ideas on how to stream images to qml efficiently?

      Any help would be very appreciated :)

      cheers!

      1 Reply Last reply Reply Quote 0
      • T
        tottv last edited by

        Found another way.. writing a customized QDeclarativeItem and connecting a signal to its update() method when a new image to render is available.. seems promising. Thanks!

        1 Reply Last reply Reply Quote 0
        • F
          fonzi337 last edited by

          QImage is one of Qt's implicitly shared classes (see "this link":http://doc.qt.nokia.com/implicit-sharing.html), so passing it by value should be extremely fast.

          1 Reply Last reply Reply Quote 0
          • T
            tottv last edited by

            bq. QImage is one of Qt’s implicitly shared classes (see this link [doc.qt.nokia.com]), so passing it by value should be extremely fast.

            I don't think that is true when QImage has a user-supplied buffer.

            http://qt-project.org/forums/viewthread/15567

            Anyway, it worked much better and faster with qdeclarativeitem, thanks!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post