Hi Ray,

You can implement this by inheriting your own image provider from
QDeclarativeImageProvider
(http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeimageprovider.html).
Using it you have a choice of returning QPixmaps and QImages. There's
a catch though. You can't modify (well you can, but you're not
achieving what you'd probably want to achieve) the QPixmap or QImage
afterwards because the interface is such that it's not returning a
reference or a pointer. If you modify it the data, the copy on write
idiom is applied. If you have a choice I think returning QPixmaps
might be better, because it's faster to draw (or if QtDeclarative does
a conversion internally, then skip the conversion).

What comes to the caching of list delegate instances, check out:
http://doc.qt.nokia.com/4.7-snapshot/qml-listview.html#cacheBuffer-prop

Juha

On Fri, Nov 12, 2010 at 7:42 PM,  <ray.rischpa...@nokia.com> wrote:
> 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
>
> _______________________________________________
> Qt-qml mailing list
> Qt-qml@trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-qml
>
>

_______________________________________________
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to