[Qt-qml] Returning a QImage to QML from C++ for a ListView delegate...
ray.rischpater at nokia.com
ray.rischpater at nokia.com
Fri Nov 12 18:42:06 CET 2010
Basically the question is: can it be done? I don’t see an obvious way.
Here’s the scenario: I’ve got a hybrid C++/QML application, where the ListView model is backed by a QStandardItemModel in C++. All that works great. However, for a variety of reasons, we would like to create the image we’re showing for each item in the model programmatically in C++, and display it in the ListView via the delegate.
The Image element takes a source attribute, so we can generate our images on the fly and drop them in a temporary directory, but I was hoping to skip the file system overhead and load the images from the heap. (Granted, for a large number of items that’s not going to be as efficient as one would like, but that’s another problem I need to deal with.)
Am I missing something obvious, or is there no way to have an Image element or the like draw from QImage or QPixmap in the C++ world? I don’t think it’s possible, as I don’t remember seeing these on the list of QML supported types, so the file system may be the only route.
A related question which may make me worry about this less: does anyone know if the ListView recycles space for the items not being shown? That is, if I have a list with twelve items and ten of them are offscreen, does it load the offscreen items on demand and drop them intelligently as stuff scrolls offscreen? Putting some debug statements in my model, it looks like loading’s pretty smart, but I haven’t drawn any conclusions about caching/cleanup yet, and haven’t read the source to know.
Thanks in advance!
Ray Rischpater
Sr. Research Engineer
Nokia Research Center Palo Alto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20101112/4254aa47/attachment.html
More information about the Qt-qml
mailing list