Create application plugin



  • I have created a Qt application (it uses R for running analyses). I want to make the application extendable using application plugins - in the sense, I want to allow anyone to make a new analysis (say linear-regression), with it's own user interface and an r package. How do I make this into a plugin?

    In the future, I want to be able to download the new "analysis-plugin" (maybe from an app store) and my qt application should be able to run it. How do I do this?

    Currently I just ship all the analyses in each release.


  • Moderators

    @swordfish
    First read this

    Then you need to think about a (robust) generic abstract interface which each plugin need to implement.
    Also the link from above says:

    1. Define a set of interfaces (classes with only pure virtual functions) used to talk to the plugins.
    2. Use the Q_DECLARE_INTERFACE() macro to tell Qt's meta-object system about the interface.
    3. Use QPluginLoader in the application to load the plugins.
    4. Use qobject_cast() to test whether a plugin implements a given interface.

    You can use QPluginLoader to load plugins from a custom folder name which then needs to rely next to the Qt plugins (somewhere in the import paths).

    The interface class can have methods like:

    class MyInterface
    {
    public:
        virtual ~MyInterface() {}
    
        virtual QWidget* getGui() const = 0;
        virtual void calculate() = 0;
    
        ..... whatever information the application needs
    };
    

  • Qt Champions 2016

    Hi
    Also for my first attempt i used
    http://doc.qt.io/qt-5/qtwidgets-tools-echoplugin-example.html

    which is pretty small and easy to understand.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.