Streaming QImage objects from C++ to QML context with QDeclarativeImageProvider
-
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: imageSenderonNewImage: { 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!
-
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.
-
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!