Results 1 to 4 of 4

Thread: QPluginLoader doesn't accept plugin name

  1. #1
    Join Date
    Apr 2011
    Posts
    31
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Exclamation QPluginLoader doesn't accept plugin name

    I'm weird. Just made plugin as described in books. All looks fine. In main application I try load it but got unexpected problem:

    Qt Code:
    1. MainWindow::MainWindow(QApplication* a, QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. QDir dir( QApplication::applicationDirPath() );
    6. QString abspath = dir.absoluteFilePath( "EmptyPlugin.dll" ); // name correct in abspath
    7. QPluginLoader PluginLoader( abspath );
    8. abspath = PluginLoader.fileName(); // name empty!!! ?????????
    9. QObject * plugin = qobject_cast<QObject*>( PluginLoader.instance() );
    10. QString errstr;
    11. if( ! plugin )
    12. errstr = PluginLoader.errorString(); // contains "Unknown error"
    13. }
    To copy to clipboard, switch view to plain text mode 

    1st time abspath is correct, but 2nd time it... is empty

    tried this:

    Qt Code:
    1. MainWindow::MainWindow(QApplication* a, QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. QDir dir( QApplication::applicationDirPath() );
    6. QString abspath = dir.absoluteFilePath( "EmptyPlugin.dll" ); // name correct
    7. QPluginLoader PluginLoader( "" );
    8. PluginLoader.setFileName( abspath );
    9. abspath = PluginLoader.fileName(); // name empty!!! ?????????
    10. QObject * plugin = qobject_cast<QObject*>( PluginLoader.instance() );
    11. QString errstr;
    12. if( ! plugin )
    13. errstr = PluginLoader.errorString(); // contains "Unknown error"
    14. }
    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!
    Last edited by Gourmet; 8th June 2011 at 12:52.

  2. #2
    Join Date
    Aug 2008
    Posts
    45
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPluginLoader doesn't accept plugin name

    Err, you have defined the abspath two times in same scope.
    Have you actually compiled your code successfully?

  3. #3
    Join Date
    Apr 2011
    Posts
    31
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QPluginLoader doesn't accept plugin name

    sorry, this was my copy-paste error just in message, I fixed it

    the code exactly is little different (like now in first message) and compiles and starts well

    I even did the following:

    Qt Code:
    1. QPluginLoader PluginLoader("");
    2. PluginLoader.setFileName( "I:/Qt/2010.05s/projects/sources/SCPS-M-build-desktop/debug/EmptyPlugin.dll" ); // file definitely exists and pathname is right
    3. QString errstr = PluginLoader.errorString(); // "Unknown error"
    4. errstr = PluginLoader.fileName(); // empty
    To copy to clipboard, switch view to plain text mode 

    and following:

    Qt Code:
    1. QPluginLoader PluginLoader("");
    2. PluginLoader.setFileName( "I:\\Qt\\2010.05s\\projects\\sources\\SCPS-M-build-desktop\\debug\\EmptyPlugin.dll" ); // file definitely exists and pathname is right
    3. QString errstr = PluginLoader.errorString(); // "Unknown error"
    4. errstr = PluginLoader.fileName(); // empty
    To copy to clipboard, switch view to plain text mode 

    both with same result

    looks like a bug in Qt 4.7 for Windows - QPluginLoader does not accept absolute plugin path

    QLibrary itself works well, I tested - but I need plugins because of C++ classes


    Added after 1:


    ANYBODY CONFIRM OR DECLINE THIS BEHAVIOUR!

    I want write bug report but need more statistic.
    Last edited by Gourmet; 8th June 2011 at 13:59.

  4. #4
    Join Date
    Apr 2011
    Posts
    31
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QPluginLoader doesn't accept plugin name

    SOLVED. Application was made static because of wrong Qt selected in it's project. Dynamically linked plugins don't work with static applications.

Similar Threads

  1. QPluginLoader not load plugin
    By Thyago.celler in forum Qt Programming
    Replies: 9
    Last Post: 20th May 2011, 19:01
  2. QPluginloader load plugin from RAM
    By meCHAoT in forum Qt Programming
    Replies: 3
    Last Post: 3rd February 2011, 17:23
  3. Replies: 8
    Last Post: 27th December 2009, 14:57
  4. QPluginLoader doesn't load plugin
    By BeS in forum Qt Programming
    Replies: 6
    Last Post: 26th November 2008, 19:12
  5. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 14:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.