Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to register QQuickAsyncImageProvider



  • I have created a QQuickAsyncImageProvider based image provider that I would like to use from my QML code, but at run time QML complains about "Invalid image provider"

    I already have a QQMLExtensionPlugin based class containing:

    void ImageProviderExtensionPlugin::registerTypes(const char *uri)
    {
        Q_UNUSED(uri);
    }
    
    
    void ImageProviderExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
    {
        Q_UNUSED(uri);
        engine->addImageProvider("orchestrator", new OrchestratorImageProvider);
    }
    

    and I reference the image in QML as: source: "image://orchestrator/myimage.png"

    What am I missing? Searching the Qt docs I see reference to creating a qmldir file (but I think that's just if I am creating an imageprovider as a lib). I also see another example that calls engine.addImageProvider but since I'm using a plugin class I don't think that's necessary.

    Can someone fill in the blank for me?


Log in to reply