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
    {
    public:
        ColorImageProvider()
            : 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);
            pixmap.fill(QColor(id).rgba());
    
            return pixmap;
        }
    };
    

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

    Thanks!


  • Lifetime Qt Champion

    Hi,

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.