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. Streaming QImage objects from C++ to QML context with QDeclarativeImageProvider
QtWS25 Last Chance

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

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

    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
    0
    • T Offline
      T Offline
      tottv
      wrote on last edited by
      #2

      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
      0
      • F Offline
        F Offline
        fonzi337
        wrote on last edited by
        #3

        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
        0
        • T Offline
          T Offline
          tottv
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved