Qt Quick Ultralite fileloading Example

Demonstrates how to load assets from external storage.


This example shows how to read assets stored on an SD Card using a file system.

The example consists of a simple screen (fileloading.qml) that shows four different historical Qt logos. The leftmost image is a regular asset included in the application binary, while the other three are being read from the file system and stored in different formats.

Target platforms

Running the example on a device

After building the example, the assets to be loaded from the file system are available in the build folder at CMakeFiles/fileloading.dir/resources/. The logos folder contains the images to copy and some additional information about the created assets. Copy the logos folder containing the images into the root directory of your SD Card. The text files are not needed during runtime and can be skipped.

Project structure

The example includes FatFS file system API implementations for STM32 and NXP platforms, and a Posix implementation in the desktop folder for Windows and Linux hosts.

The main functions in os/baremetal and os/freertos will call a ConfigureBoard() function that has to be implemented for a board. This function has to setup the SD Card hardware and register the file system with Qt Quick Ultralite.

Implementations for this functions are available at board_config.cpp in sub-folders named after the platforms (desktop, stm, nxp).

The 3rdparty folder contains auxiliary code provided by other parties, like the FatFS implementation for embedded devices.

fatfs/fatfsfilesystem.h contains the API integration of the FatFS code to the Qt Quick Ultralite API. Details on how to integrate a custom file system with Qt Quick Ultralite are described in File system integration.

Using images from a file system

In QML it is possible to access image files from a file system with the file:// protocol.

Image {
    source: "file://logos/2008.png"

The assets are converted to a format that is optimized for being rendered on the target device.

ImageFiles {
    files: [ "2008.png" ]
    MCU.prefix: "logos"
    MCU.resourceAsFile: true
    MCU.resourceCompression: false

To use assets as file resources, you need to enable the MCU.resourceAsFile property. You can also apply other asset properties described in Managing Resources, such as adding a prefix to the image path or enabling RLE compression.



See also Qul::PlatformInterface::Filesystem and Qul::PlatformInterface::File.

Available under certain Qt licenses.
Find out more.