Qt 4.8 to 5.0 - QPluginLoader->instance returns NULL



  • Hello there,

    I've written an Application by using QT 4.8.2. It does dynamically load different plugins to provide multiple functions for the user.
    Now Qt5 was released and I wanted to convert my project to the newest version.

    I got everything to work, except loading the plugin with QPluginLoader->instance(). While using Qt 4.8.2 it worked fine.

    ->errorString says:
    "The file '.../plugins/nlprod.dll' is not a valid Qt plugin."

    That's my code:

    PluginLoader.cpp:
    @
    //"fileName" contains the name of the .dll
    pluginLoader->setFileName(pluginsDir->absoluteFilePath(fileName));

        //"a" contains the correct path + name of the .dll
        QString a = pluginLoader->fileName();       
    
        //"plugin" is null and success "false"
        QObject *plugin = pluginLoader->instance();
        bool success = pluginLoader->isLoaded();
    

    @

    MyPlugin.h:
    @
    class NLPro : public QObject, IConnection
    {
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "NLPro" FILE "nlpro.json") // <- New since I've ported to Qt 5
    Q_INTERFACES(IConnection)
    ...
    }
    @

    MyPlugin.cpp:
    I've deleted the following:
    @
    Q_EXPORT_PLUGIN2(NLPro, NLPro);
    @

    and I've added a .json-file with the following content:
    @
    { "Keys": [ "NLPro"] }
    @

    Any idea?

    Thanks in advance!

    Regards


Log in to reply
 

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