C

ImageProvider Struct

struct Qul::ImageProvider

The ImageProvider class provides an interface for supporting image requests in QML. More...

Header: #include <qul/imageprovider.h>
Since: Qt Quick Ultralite 1.5

Public Functions

virtual Qul::SharedImage requestImage(const char *uri, size_t uriLength) = 0

Detailed Description

ImageProvider is used to provide advanced image loading features in QML applications.

To use an image provider to load images, use the "image:" scheme in the URL of the image, followed by the identifiers of the image provider and the requested image. For example:

Image { source: "image://myimageprovider/image.png" }

This specifies that the image must be loaded by the image provider named "myimageprovider", and the image to be loaded is named "image.png". Qt Quick Ultralite invokes the appropriate image provider according to the providers that have been registered through Qul::Application::addImageProvider().

Note: The identifiers and the rest of the URL are case-sensitive, contrary to QQuickImageProvider. For example, the snippet above specifies that the image is loaded from the image provider called "myimageprovider" and the snippet below uses the image provider called "MyImageProvider". Additionally, the example below requests two different images ("Image.png" and "image.png").

Image { source: "image://MyImageProvider/image.png" }
Image { source: "image://MyImageProvider/Image.png" }

See also Qul::Application::addImageProvider.

Member Function Documentation

[pure virtual] Qul::SharedImage ImageProvider::requestImage(const char *uri, size_t uriLength)

Implement this method to return the image for the uri and uriLength.

The uri is the requested image source, with the "image://" scheme and provider identifier removed. For example, if the image source is "image://myprovider/icons/home", the given uri would be "icons/home".

This function may start an asynchronous loading operation and return an unfinished image. To do that, call Image::beginWrite() before returning and call Image::endWrite() when loading has finished.

Note: Image::endWrite() is not thread safe. Use EventQueue to send an event and call endWrite() in the event handler.

Available under certain Qt licenses.
Find out more.