Hello,
i'm working on a program which has a QMdiArea. The QMdiSubWindows are QPlugins which can be loaded during runtime.
This is the current plugin Interface:
#ifndef INTERFACE_H
#define INTERFACE_H
#include <QtPlugin>
class PluginInterface
{
public:
virtual ~PluginInterface() { }
};
Q_DECLARE_INTERFACE(PluginInterface, "foo.demo.PluginInterface/1.0")
#endif
#ifndef INTERFACE_H
#define INTERFACE_H
#include <QtPlugin>
class PluginInterface
{
public:
virtual ~PluginInterface() { }
virtual QString getName() = 0;
virtual QWidget* getWidget() = 0;
};
Q_DECLARE_INTERFACE(PluginInterface, "foo.demo.PluginInterface/1.0")
#endif
To copy to clipboard, switch view to plain text mode
in getWidget() i load or create a widget and than the main program can get the widget with getWidget() and put it into a QMdiSubWindow.
So far it works quite well.
But now i want to have some communication between the plugins. E.g. if i press a button in one plugin something should happen in the other plugin.
I have tried to give the plugins a reference to their communication partner when i load a plugin. But it doesn't work. I think the problem was that i always casted the plugins down to qwidget and than within the plugin again up to foobar-plugin but than of course all the special foobar-plugin methods are lost due the "down-cast". But the main program doesn't know about all possible plugin classes. So i'm stuck and don't know how to solve the problem.
Can you give me some hints how i could achieve this?
Thanks!
Bookmarks