I have a QML Flickable with 3 QML image elements that cycle through 8 image files. My problem is that this uses a lot of memory on a Symbian device with very little. So when someone minimizes the app there isn't a lot of memory left for other apps. I want to know what function I can use on the focus lost event to release the cache. Otherwise Symbian closes my app when the phone runs out of memory.
相关问题
- Views base64 encoded blob in HTML with PHP
- Sorting 3 numbers without branching [closed]
- QML: Cannot read property 'xxx' of undefin
- QML: Cannot read property 'xxx' of undefin
- How to get the background from multiple images by
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- Use savefig in Python with string and iterative in
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
Have tried just setting the image element cache property to false ? Or maybe bind the image element cache property to somekind of focus/active property of your application ?
I just ran into a very similar situation (literally). Apparently the QML cache is hardcoded deep inside the Qt source. I found a relevant posting at http://lists.qt.nokia.com/pipermail/qt-qml/2011-June/002743.html.
Unfortunately, a solution deriving from that link requires modifying your Qt build. I don't know if that's appropriate for your situation.
My current thinking is that the four constants defined at the top of src/declarative/util/qdeclarativepixmapcache.cpp file (lines 66-69, referenced from the above link) control when and why the QML image cache is modified. I'm setting the CACHE_EXPIRE_TIME constant to 0, as further logic inside that file indicates that with the constant set to 0, items in the cache expire immediately, and will therefore be removed. I'll update this answer as things develop.
Edit:
My proposed solution did work. In the QDeclarativePixmapCache.cpp file, change line 68 from
to
Rebuild Qt and your application, and images will not be cached (or at least, the behavior I'm seeing would indicate that images are no longer being cached). There are a couple of downsides to this solution:
This solution worked with Qt version 4.7. Good luck!