Solved Again Lowlevel Plugins
-
Hi
A had another Question for Plugins.
Must i define all Functions in the base Interface?
I create a PluginInterface Plugin
I create a new Interface like
class MyPlugin: public Plugin
and add some functions.
When i doQPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); QObject *plugin = pluginLoader.instance(); if (plugin) { Plugin *myPlugin = qobject_cast<Plugin *>(plugin); if (myPlugin) ....
it works, but myPlugin to not have my funktion
i must doQPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); QObject *plugin = pluginLoader.instance(); if (plugin) { MyPlugin *myPlugin = qobject_cast<MyPlugin *>(plugin); if (myPlugin) ....
How can i handle this in an PluginManager? Must i recompile my corelib when i add a new Plugin with other functions? Or should i use a call-method
-
It is 100% like normal c++
If they are not virtual / part of base class,
then you must cast to the correct type to call a function, only that type has. -
Hi,
The common library should contain the all the interfaces your plugins might implement. Then in your plugin manager, you check whether your actual plugin implement the interface you want to use.
Your plugins can implement several different interfaces. Take a look at the Plug And Paint example.
-
Ohh.
When i'm right so i can create some Interfaces and include one ore more of them in a Plugin. This Plugin has than Interface "MyInterface" with the functions of the Included.
So it is better to add the Interfaces to the corelib where my Pluginmanager is included. And use them in my new Plugins.
-
@mrjj I must cast MyPlugin to Plugin
Plugin *myPlugin = qobject_cast<MyPlugin *>(plugin);
or MyPlugin to MyPlugin ;)
MyPlugin *myPlugin = qobject_cast<MyPlugin *>(plugin);
-
Yes, the interfaces will then be known to both.
-
Nice, this helps me. Thx