Qt Quick Ultralite image_cache Example

Demonstrates how to use image cache in Qt Quick Ultralite.


The example shows two sets of images. The current set is changed every reloadInSeconds seconds and the cache size is set to fit 4 images at a time, which is the amount of images in each image set. Thus, the cache can hold all images from the currently active image set. Images are loaded into the cache when they are requested to be rendered on the display - when a new image is accessed by swiping. When the cache is full, it removes the oldest image to free the space for the currently requested image.

Target platforms

Project structure

The image cache is enabled in the CMake project file.

CMake project file

Set the QUL_TEXTURE_CACHE and QUL_DEFAULT_COPY_TO_RAM CMake variables. These CMake variables enables image cache and sets the copy-to-ram behavior to OnDemand for all the resources.

Setting the copy-to-ram behavior on individual resources is possible by using QUL_COPY_TO_RAM CMake variable. This can be useful when only certain images in the application should be eligible to be cached.

Note: Ensure that these variables are set before the qul_add_target and qul_add_resource calls.

set(QUL_TEXTURE_CACHE ${cache_size_in_bytes})
qul_add_target(image_cache ImageModel.cpp)

If your target OS is FreeRTOS, set the heap size


Now, whenever the image is about to get drawn, the renderer checks the cache first.



See also QUL_COMPRESSION and Image Caching.

Available under certain Qt licenses.
Find out more.