I'm working on a plugin interface, which will be used to load a set of QWidgets into a host application. Currently, the interface provides a getWidget() method, which returns an instance to the widget. This method sounds obvious enough, but the problem lies in how the host application is handling the widgets. The host application only knows how to manage QWidget instances and not instances to a plugin's interface, thus losing access to other methods in the interface.

I have been able to solve this by having the interface class inherit QWidget. Subclassing QWidget ensures the interface methods are retained by the host application's widget manager.

See examples below...

First method:
class MyInterface1 {
public:
virtual void someMethod() = 0;
virtual QWidget* getWidget() = 0;
};

class MyPlugin1 : public QWidget, public MyInterface1 {
public:
void someMethod();
QWidget* getWidget();
};


Second method:
class MyInterface2 : public QWidget {
public:
virtual void someMethod() = 0;
};

class MyPlugin2 : public MyInterface2 {
public:
void someMethod();
};


My problem with this is that by subclassing QWidget, my interface class has wandered beyond the scope of being a pure plugin interface. Anyone else think there is a better approach?

Apologies if I may have confused anyone