View Full Version : QPluginLoader not load plugin

17th May 2011, 21:55

I have a problem, when I use QPluginLoader,the return is empty. But the path it is correct.

This is my code:

QDir dir( QCoreApplication::applicationDirPath());

qDebug() << dir.absoluteFilePath(fileName);
QPluginLoader loader(" dir.absoluteFilePath(fileName)");

qDebug() << loader.isLoaded();
qDebug() << loader.errorString();
QObject *plugin = loader.instance();

The result in line :

1. qDebug() << dir.absoluteFilePath(fileName); is "path this is right", including the name file.

2. qDebug() << loader.isLoaded(); is "false"

3. qDebug() << loader.errorString(); is "unknow error".

and line:

Please, help me. =)


17th May 2011, 23:46
Does the plugin have the Q_EXPORT_PLUGIN2 macro?

18th May 2011, 00:32
At line 6 you ask QPluginLoader to load a plugin called literally: " dir.absoluteFilePath(fileName)"

Remove the quotes.

18th May 2011, 16:11

I remove the quotes, but did not difference.

Other question, where I put the macro Q_EXPORT_PLUGIN2 ?

Thank you very much.

18th May 2011, 16:24
In the implementation of the plugin, just like the docs state.

19th May 2011, 16:30
The problem is that, I not create the file .dll, he already exist in folder of project.

I just want import or load this file. That will I have that create the file .dll, ever that the project is compiled ?

thank you.

19th May 2011, 17:06
I don't understand what you mean. But to use the plugin, the macro needs to be there. You need to check if it is there.

20th May 2011, 03:54
I think Thyago.celler wants to dynamically load an arbitrary library, not a Qt plugin. The correct class for this would be QLibrary not QPluginLoader.

20th May 2011, 18:49
But the that I'm doing this correct, but it returns me the following error :

Use incompatible Qt library. Expected build key ""Windows mingw debug full-config"" got, "Windows mingw release full-config";

Someone hnow the that can be this and why ?

Thank you.

20th May 2011, 20:01
Your application is built in debug mode and the library is built in release mode. They have to be built in the same mode (either debug or release).