Qt Quick Shared Image Provider | Qt Quick | Qt 6.11.1
Description: Adds an image provider which utilizes shared CPU memory

- Qt 6.11
- Qt Quick
- Qt Quick Shared Image Provider
- Qt 6.11.1 Reference Documentation

C++ Extension Points ◦ Qt Quick for Android

# Qt Quick Shared Image Provider

### Summary

This module provides functionality to save memory in use cases where several Qt Quick applications use the same local image files. It does this by placing the decoded QImage data in shared system memory, making it accessible to all the processes (see QSharedMemory).

This module only shares CPU memory. It does not provide sharing of GPU memory or textures.

### Usage

To use this module, import it like this:

     import Qt.labs.sharedimage

The sharing functionality is provided through a QQuickImageProvider. Use the "image:" scheme for the URL source of the image, followed by the identifier shared, followed by the image file path. For example:

     Image { source: "image://shared/usr/share/wallpapers/mybackground.jpg" }

This will look for the file /usr/share/wallpapers/mybackground.jpg. The first process that does this will read the image file using normal Qt image loading. The decoded image data will then be placed in shared memory, using the full file path as key. Later processes requesting the same image will discover that the data is already available in shared memory. They will then use that instead of loading the image file again.

The shared image data will be kept available until the last process has deleted its last reference to the shared image, at which point it is automatically released.

If system memory sharing is not available, the shared image provider falls back to normal, unshared image loading.

The file path must be absolute. To use a relative path, make it absolute using Qt.resolvedUrl() and replace the URL scheme. For example:

     ...
     property string imagePrefix: Qt.resolvedUrl("../myimages/").replace("file://", "image://shared/")
     Image { source: imagePrefix + "myimage.png" }

The shared image module does not provide any directly usable QML types.

C++ Extension Points ◦ Qt Quick for Android