Results 1 to 3 of 3

Thread: [SOLVED] Q_EXPORT_PLUGIN2 vs. $$qtLibraryTarget()

  1. #1
    Join Date
    Jun 2006
    Posts
    81
    Thanks
    6
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Question [SOLVED] Q_EXPORT_PLUGIN2 vs. $$qtLibraryTarget()

    Hi all,

    I have a plugin foo that I build to TARGET = $$qtLibraryTarget(foo). This implies that under Windows, the debug plugin is named food.dll (mark the trailing 'd' character).

    I use Q_EXPORT_PLUGIN2(PluginName, FooClass) to export the plugin class. As the doc states:
    The value of PluginName should correspond to the TARGET specified in the plugin's project file.
    So the 1st parameter to Q_EXPORT_PLUGIN2 needs to fit the appropriate build configuration.
    Of course I could use #ifdef to preprocess with a different macro parameter depending on the configuration. However, I dislike this option as it requires manual synchronization between plugin implementation source and .pro file.

    Is there a better way to automagically adopt Q_EXPORT_PLUGIN2's PluginName to the TARGET?

    Thank you for your help and proposals.
    Last edited by zaphod.b; 24th July 2009 at 14:42.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Q_EXPORT_PLUGIN2 vs. $$qtLibraryTarget()

    I think using "foo"in Q_EXPORT_PLUGIN2() should be fine.

    For example the GIF image format plugin of Qt does it like this:

    gif.pro:
    Qt Code:
    1. TARGET = qgif
    2. include(../../qpluginbase.pri)
    To copy to clipboard, switch view to plain text mode 
    qpluginbase.pri:
    Qt Code:
    1. TARGET = $$qtLibraryTarget($$TARGET)
    To copy to clipboard, switch view to plain text mode 
    main.cpp:
    Qt Code:
    1. Q_EXPORT_PLUGIN2(qgif, QGifPlugin)
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    zaphod.b (25th August 2009)

  4. #3
    Join Date
    Jun 2006
    Posts
    81
    Thanks
    6
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default [SOLVED] Q_EXPORT_PLUGIN2 vs. $$qtLibraryTarget()

    Thx jpn, you're right.

    My build environment was in a state where I could only load the plugin when I put the trailing 'd' to PluginName in Q_EXPORT_PLUGIN2. Maybe some plugin cache issue?

    Anyway, i did a major cleanup and everything works as expected. No need to take care of the configuration there explicitly.

    Sorry for stirring up.

Tags for this Thread

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.