[SOLVED] QPluginLoader unable to load a Qt Plugin
-
Hello all,
I have an Interface as shown below.
class MyInterface { public: virtual ~MyInterface() {} virtual int initialize() = 0; }; Q_DECLARE_INTERFACE(MyInterface, "com.example.MyInterface/1.0")
My plugin implements this interface and declares it in its class as shown below.
class QT_DECL_EXPORT MyPlugin : public QObject, public MyInterface { Q_OBJECT Q_INTERFACES(MyInterface) public: MyPlugin(); virtual ~MyPlugin(); public: int initialize(); // ... };
My plugin's project file sets the target appropriately.
TARGET = $$qtLibraryTarget(MyPlugin) TEMPLATE = lib
Now, all the modules (including my app) gets compiled. In the app where I have to load the plugin, I have the following code:
// ... QPluginLoader loader("MyPluginld.dll"); if (! loader.load()) qDebug() << "Error!"; MyInterface *base = qobject_cast<MyInterface *>(loader.instance()); if (base == NULL) qDebug() << "Error!"; // ...
The
loader.load()
function always fails. Am I making a mistake by providing incorrect name to theQPluginLoader
constructor? Or is something else wrong?Any help would be much appreciated.
Cheers!
Bharath