[Qt-qml] Can you access the Image element's cached QImage/QPixmap from C++ code?

Juha Turunen turunen at iki.fi
Fri Jan 14 21:25:47 CET 2011


O hai,

QML items use QPixmapCache
(http://doc.qt.nokia.com/latest/qpixmapcache.html). Whenever you use
an image (I think in 4.7.2 you can opt out though) it gets cached in
QPixmapCache. Eventually pixmaps will be thrown out of the cache if a
lot of them are used, but chances are that it's still there in the
cache. The key is probably the URL you loaded it from.

Juha

On Thu, Jan 13, 2011 at 10:23 PM, T C <teeceeare97 at gmail.com> wrote:
> Say your QML gui has a section with an Image element whose source points to
> some internet image (http://somwhere/myphoto.jpg for example).  When the
> Image item is instantiated the default image provider retrieves it (in the
> background maybe) and then it is painted when ready.  The QImage is then
> cached somewhere by the image provider using the source url as the key.
> Later on I would like my C++ code to be able to save this image to permanent
> storage, if the user chooses to do so.  Is there a way to do this by
> directly accessing the cached QImage?
>
> I understand that I can write a custom image provider and plug that in to
> the QML app context, but I really don't want to redo all the stuff that
> loads remote images in background threads if I don't have to.   Is there an
> easier way?
>
>
>
> _______________________________________________
> Qt-qml mailing list
> Qt-qml at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-qml
>
>


More information about the Qt-qml mailing list