Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 4.8 to 5.0 - QPluginLoader->instance returns NULL
Forum Updated to NodeBB v4.3 + New Features

Qt 4.8 to 5.0 - QPluginLoader->instance returns NULL

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Feyh
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved