Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Caching many PNG images-files in one go.
Snoopy last edited by
In my Qt Quick Application I want to cache 120 image-files in PNG-Format by set the property cache = true for the Image items. Every image with a size below 20 KB. So in total not more than 2.5 MB.
- question: Which negative consequences or problems are to expected by caching all the images ?
2.question: At the moment there are 120 Images items in my application. Everyone with property cache = true. But I'm skeptical that this is the correct way. Has somebody an idea how to do that correctly ?
Maybe dynamically creating with a loop when the application is starting. I'm not sure.
Thanks. Best regards
timday last edited by timday
@Snoopy Does the application have any knowledge of which images are likely to be needed next? For example, does it just cycle through them as an animation? Or are they used by a collection of screens/pages such that from any given page the user can only see certain images and only access certain other pages which use a certain subset of the images?
I've found QQuickImageProvider http://doc.qt.io/qt-5/qquickimageprovider.html to be useful for implementing various behaviours attempting to be smarter (or more tuned for the application) than Qt's own default cache logic. Part of the problem certainly used to be that the cache isn't actually that big... there's an interesting bug https://bugreports.qt.io/browse/QTBUG-19507 from back in the "declarative" days... I've no idea how big it is these days. BTW I believe images are cached uncompressed... so they could be occupying considerably more than 20KB each in the QtQuick image cache. If you loaded them via a QQuickImageProvider you can take a lot more control over what form they're cached in.