I think that your plugin can be abstract factory, so the interface can look like this:
class Interface
{
public:
};
// in plugin:
class Plugin : public Interface
{
/* ... */
};
QWidget * Plugin
::createWidgetForName(const QString & widgetName
) const {
if (name == "WidgetOne")
return new WidgetOne(parent);
if (name == "WidgetTwo")
return new WidgetTwo(parent);
}
class Interface
{
public:
QStringList availableWidgets() const = 0;
QWidget * createWidgetForName(const QString & widgetName, QWidget * parent = 0) const = 0;
};
// in plugin:
class Plugin : public Interface
{
/* ... */
};
QWidget * Plugin::createWidgetForName(const QString & widgetName) const
{
if (name == "WidgetOne")
return new WidgetOne(parent);
if (name == "WidgetTwo")
return new WidgetTwo(parent);
}
To copy to clipboard, switch view to plain text mode
In such situation you can only declare that interface and made as many widgets as you want in you plugin shared library. The problem is that all the widgets you get as QWidget so you dont know anything about custom methods etc. So you have to include custom widgets headers in you main application and qobject_cast them.
At least that is what I would do
when I face your problem.
P.S. Ohh, of course you can also use Property System and interact with widgets with property() and setProperty()
Bookmarks