I'm weird. Just made plugin as described in books. All looks fine. In main application I try load it but got unexpected problem:
ui(new Ui::MainWindow)
{
QString abspath
= dir.
absoluteFilePath( "EmptyPlugin.dll" );
// name correct in abspath abspath = PluginLoader.fileName(); // name empty!!! ?????????
QObject * plugin
= qobject_cast<QObject
*>
( PluginLoader.
instance() );
if( ! plugin )
errstr = PluginLoader.errorString(); // contains "Unknown error"
}
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"
}
To copy to clipboard, switch view to plain text mode
1st time abspath is correct, but 2nd time it... is empty 
tried this:
ui(new Ui::MainWindow)
{
QString abspath
= dir.
absoluteFilePath( "EmptyPlugin.dll" );
// name correct PluginLoader.setFileName( abspath );
abspath = PluginLoader.fileName(); // name empty!!! ?????????
QObject * plugin
= qobject_cast<QObject
*>
( PluginLoader.
instance() );
if( ! plugin )
errstr = PluginLoader.errorString(); // contains "Unknown error"
}
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"
}
To copy to clipboard, switch view to plain text mode
effect is the same, no plugin file name assigned
why this can happen? PLEASE HELP!
Bookmarks