Gourmet
8th June 2011, 10:23
I'm weird. Just made plugin as described in books. All looks fine. In main application I try load it but got unexpected problem:
MainWindow::MainWindow(QApplication* a, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QDir dir( QApplication::applicationDirPath() );
QString abspath = dir.absoluteFilePath( "EmptyPlugin.dll" ); // name correct in abspath
QPluginLoader PluginLoader( abspath );
abspath = PluginLoader.fileName(); // name empty!!! ?????????
QObject * plugin = qobject_cast<QObject*>( PluginLoader.instance() );
QString errstr;
if( ! plugin )
errstr = PluginLoader.errorString(); // contains "Unknown error"
}
1st time abspath is correct, but 2nd time it... is empty :confused:
tried this:
MainWindow::MainWindow(QApplication* a, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QDir dir( QApplication::applicationDirPath() );
QString abspath = dir.absoluteFilePath( "EmptyPlugin.dll" ); // name correct
QPluginLoader PluginLoader( "" );
PluginLoader.setFileName( abspath );
abspath = PluginLoader.fileName(); // name empty!!! ?????????
QObject * plugin = qobject_cast<QObject*>( PluginLoader.instance() );
QString errstr;
if( ! plugin )
errstr = PluginLoader.errorString(); // contains "Unknown error"
}
effect is the same, no plugin file name assigned
why this can happen? PLEASE HELP!
MainWindow::MainWindow(QApplication* a, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QDir dir( QApplication::applicationDirPath() );
QString abspath = dir.absoluteFilePath( "EmptyPlugin.dll" ); // name correct in abspath
QPluginLoader PluginLoader( abspath );
abspath = PluginLoader.fileName(); // name empty!!! ?????????
QObject * plugin = qobject_cast<QObject*>( PluginLoader.instance() );
QString errstr;
if( ! plugin )
errstr = PluginLoader.errorString(); // contains "Unknown error"
}
1st time abspath is correct, but 2nd time it... is empty :confused:
tried this:
MainWindow::MainWindow(QApplication* a, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QDir dir( QApplication::applicationDirPath() );
QString abspath = dir.absoluteFilePath( "EmptyPlugin.dll" ); // name correct
QPluginLoader PluginLoader( "" );
PluginLoader.setFileName( abspath );
abspath = PluginLoader.fileName(); // name empty!!! ?????????
QObject * plugin = qobject_cast<QObject*>( PluginLoader.instance() );
QString errstr;
if( ! plugin )
errstr = PluginLoader.errorString(); // contains "Unknown error"
}
effect is the same, no plugin file name assigned
why this can happen? PLEASE HELP!