QQuickImageProvider - requestImage() not implemented



  • Hey guys,

    I'm trying to pass a QImage to QML via QQuickImageProvider. Once QML requests the image I receive the following error:

    "(null):0 ((null)): ImageProvider supports Image type but has not implemented requestImage()"

    My provider looks as follows:

    source:

    #include "qmlimageprovider.h"
    
    QmlImageProvider::QmlImageProvider()
        :QQuickImageProvider(QQuickImageProvider::Image)
    {
    }
    QmlImageProvider::~QmlImageProvider()
    {
    }
    
    void QmlImageProvider::setPic(QImage cameraFrame)
    {
        this->cameraFrame = cameraFrame;
        emit cameraFrameReady();
    }
    
    QImage QmlImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize, bool requestedAutoTransform)
    {
        Q_UNUSED(id);
        Q_UNUSED(size);
        Q_UNUSED(requestedSize);
        Q_UNUSED(requestedAutoTransform);
    
        qDebug() << "Request Image";
    
        return this->cameraFrame;
    }
    
    

    header:

    #ifndef QMLIMAGEPROVIDER_H
    #define QMLIMAGEPROVIDER_H
    
    #include <QQuickImageProvider>
    #include <QDebug>
    
    class QmlImageProvider : public QObject, public QQuickImageProvider
    {
        Q_OBJECT
    
        public:
            explicit QmlImageProvider();
            ~QmlImageProvider();
    
            void setPic(QImage cameraFrame);
    
        protected:
            virtual QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize, bool requestedAutoTransform);
    
        signals:
            void cameraFrameReady();
    
        private:
            QImage cameraFrame;
    };
    
    #endif // QMLIMAGEPROVIDER_H
    
    

    Thanks in advance!


  • Moderators

    Shouldn't requestImage(...) be public?


Log in to reply
 

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