Results 1 to 4 of 4

Thread: What is the point of plugins?

  1. #1
    Join Date
    Mar 2010
    Posts
    8
    Thanks
    7
    Qt products
    Qt4

    Default What is the point of plugins?

    I am aware that you can extend qt features and application with plugins but what is the deal with all complications(macros, plugin commands, plugin loading etc) couldnt you just make a simple class and extend your app like that?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: What is the point of plugins?

    The big point is that you can extend your application without rebuilding it. Even if you alter your plugin, you don't have to recompile your app. (That's important if your app is huge and needs lot of time for compiling.) Further you can load your only the needed plugins at runtime. Thus the resources for your application are lower compared to a "full including" application.

    Another thing is, that others can develop plugins for your application and use it. You don't have to give them your sources.
    Last edited by Lykurg; 31st July 2010 at 06:06. Reason: updated contents

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

    msimurin (31st July 2010)

  4. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: What is the point of plugins?

    Quote Originally Posted by msimurin View Post
    I am aware that you can extend qt features and application with plugins but what is the deal with all complications(macros, plugin commands, plugin loading etc) couldnt you just make a simple class and extend your app like that?
    There are a few obvious reasons why you can't just do that.

    Plugins use the Factory design pattern. This means you create an abstract base class and then create implementation classes based on that base class. The plugin loader acts as the factory. You can have a function called bool hasCapabilities(...) in your abstract class and the factory can use it to determine which plugin should be used.

    Loading of the plugins is also straightforward. You can't expect your program to find and open plugins on its own. How would it do that? Instead, you place the plugins in a special folder, known either by the system or your program. Then you look into this folder and use the factory (plugin loader) to open (create) those plugins.

    Then there are the macros. Since you're dealing with separate libraries you need to tell if you are importing symbols into your library or exporting them to another program or plugin. This is important, because if you don't tell if you're importing or exporting, the program will not find the implementation of your abstract base class in the plugin.

  5. The following user says thank you to tbscope for this useful post:

    msimurin (31st July 2010)

  6. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: What is the point of plugins?

    Also, the macros and the rest of the Qt plugin framework ensures cross-platform compatibility. Once your code works on one machine, it can be recompiled and run on a completely different platform without any changes. If you've tried writing dynamic libraries using the "raw" approach, you'll know how many differences arise between, say, Linux and Windows.

    And at the end of the day, using native libraries and function calls is considerably more complex than using Qt's handful of macros.

  7. The following user says thank you to SixDegrees for this useful post:

    msimurin (31st July 2010)

Similar Threads

  1. Mac OS, plugins that user designer plugins
    By Royceybaby in forum Qt Programming
    Replies: 0
    Last Post: 9th May 2010, 01:40
  2. Replies: 1
    Last Post: 3rd December 2009, 14:23
  3. What the point of using -GL
    By pyfqrf in forum Qt Programming
    Replies: 1
    Last Post: 18th May 2009, 18:00
  4. display a plot point by point
    By oswalidos in forum Newbie
    Replies: 32
    Last Post: 13th March 2009, 15:37
  5. how to paint scene point by point
    By elessaar in forum Qt Programming
    Replies: 8
    Last Post: 4th September 2008, 20:00

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
  •  
Qt is a trademark of The Qt Company.