Well, I'm trying to loading the echoplugin, inculded in the Qt's 4.6.0 package from my application but i can't done it. I'm compiling on Windows with Visual Studio and VS Add-in, all projects works fine, and if i compile the Echoplugin example, it loads the plugin fine, but my application can't do it.
Here is the function:
{
ui.setupUi(this);
QDir pluginsDir
(qApp
->applicationDirPath
());
pluginsDir.cd("plugins");
foreach
(QString fileName,pluginsDir.
entryList(QDir::Files)) {
QPluginLoader pluginLoader
(pluginsDir.
absoluteFilePath(fileName
));
QObject *plugin
= pluginLoader.
instance();
if (plugin)
{
QMessageBox::information(this,
"xD",
"Plugin cargado!!! :D");
}
else
{
QMessageBox::information(this,
"xD",pluginLoader.
errorString());
}
}
return;
}
Programa::Programa(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags)
{
ui.setupUi(this);
QDir pluginsDir(qApp->applicationDirPath());
pluginsDir.cd("plugins");
foreach (QString fileName,pluginsDir.entryList(QDir::Files))
{
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
QObject *plugin = pluginLoader.instance();
if (plugin)
{
QMessageBox::information(this,"xD","Plugin cargado!!! :D");
}
else
{
QMessageBox::information(this,"xD",pluginLoader.errorString());
}
}
return;
}
To copy to clipboard, switch view to plain text mode
QPluginLoader::instance() returns always null, and the QPluginLoader::errorString() returns "Unknown Error". I think that the code isn't the problem, so i suspect that error could be in the project configuration. ?
Thanks in advance
Bookmarks