Juha Turunen <turu...@...> writes:

> 
> 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).
> 
> Juha
> 
> On Fri, Nov 12, 2010 at 7:42 PM,  <ray.rischpa...@...> 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.)
> >
> > ...
> >
> > Ray Rischpater
> >
> > Sr. Research Engineer
> >
> > Nokia Research Center Palo Alto

Hi,

I have faced the same problem as Ray. And think that the
QDeclarativeImageProvider does not help here, at least not directly.

When you have a list object existing in native C++ side and you wan't to
populate the QML ListView with it. For "normal" data like integers and strings
it works fine by using QDeclarativeListProperty.

But the problem comes when you want to have an individual image for each list
item. With QDeclarativeImageProvider you can populate the list items with the
same image instance, but how to have an individual image for each item seems to
be problematic.

Br, Tuomas




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

Reply via email to