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.
-
@swordfish
First read thisThen you need to think about a (robust) generic abstract interface which each plugin need to implement.
Also the link from above says:- Define a set of interfaces (classes with only pure virtual functions) used to talk to the plugins.
- Use the Q_DECLARE_INTERFACE() macro to tell Qt's meta-object system about the interface.
- Use QPluginLoader in the application to load the plugins.
- 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 };
-
Hi
Also for my first attempt i used
http://doc.qt.io/qt-5/qtwidgets-tools-echoplugin-example.htmlwhich is pretty small and easy to understand.