Michał Walenciak
Michał Walenciak

Reputation: 4369

use in memory file with QML's Image

In my application I generate a lot of different images (I keep them as QImage objects) and I was wondering if it would be possible to use these objects more or less directly with QML Image? The only option I see is to write them to disk and then pass path to Image.source. Is there any trick to avoid it?

Additional info: apart from static QIMages I also plan to generate gifs and possibly other files (all in memory) which I'll try to use with AnimatedImage or MediaPlayer so workaround for static image only is not enough for me.

Upvotes: 1

Views: 1085

Answers (1)

JarMan
JarMan

Reputation: 8277

I think what you're looking for is a QQuickImageProvider. It allows your QML app to request images/pixmaps from a C++ class that you provide. The data can then come from anywhere you like, including an in-memory QImage. The example provided here shows how to generate a pixmap on the fly and provide it to a QML Image object.

Upvotes: 2

Related Questions