Important: Please read the Qt Code of Conduct -

QQuickImageProvider not recieving Unicode from Qml - cannot find image

  • Hi,
    I am building an application with a QML image source that is set from C++ backend. My problem being the QQuickImageProvider I have attached to my application engine as an image provider takes in the image source data as a QString in the requestPixmap function - using the example provided in QQuickImageProvider doc

    class ColorImageProvider : public QQuickImageProvider
            : QQuickImageProvider(QQuickImageProvider::Pixmap)
        QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
            int width = 100;
            int height = 50;
            if (size)
                *size = QSize(width, height);
            QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width,
                           requestedSize.height() > 0 ? requestedSize.height() : height);
            return pixmap;

    How can I ensure the Unicode string properly propagates from C++ backend to QML back to QQuickImageProvider::requestPixmap()?


  • Lifetime Qt Champion


    Can you show how you are using your provider in your code ? As well as an example of string ?

Log in to reply