I don't really see a problem in doing this the way I said I made a few plugins in my life (both using and not using the Qt plugin framework) and they always worked as expected in the form I suggested. COM seems to work too, Java implementing interfaces seems to work, other languages as well... I don't really see a problem in creating an implementation of an interface that returns an instance of implementation of another interface...

I think it should look more or less like so:
Qt Code:
  1. struct MyInterface {
  2. virtual void method1() = 0;
  3. virtual void method2() const = 0;
  4. virtual int method3() = 0;
  5. virtual double method4(int) = 0;
  6. virtual ~MyInterface(){}
  7. };
  8.  
  9. struct PluginInterface {
  10. virtual ~PluginInterface(){}
  11. virtual MyInterface *create(QWidget *parent=0) = 0;
  12. };
  13. Q_DECLARE_INTERFACE(PluginInterface, "xxx")
To copy to clipboard, switch view to plain text mode 

And implementation:
Qt Code:
  1. struct MyInterfaceImpl : public QObject, public MyInterface {
  2. MyInterfaceImpl(QWidget *parent = 0) : QObject((QObject*)parent){}
  3. void method1(){ printf("BLABLA\n"); }
  4. void method2() const { printf("BLABLA\n"); }
  5. int method3() { return 7; }
  6. double method4(int a) { return a*1.0/7.0; }
  7. ~MyInterfaceImpl(){}
  8. };
  9.  
  10. struct Plugin : public QObject, public PluginInterface {
  11. Q_OBJECT
  12. Q_INTERFACES(PluginInterface)
  13. Plugin(QObject *parent=0) : QObject(parent){}
  14. ~Plugin(){}
  15. MyInterface *create(QWidget *parent=0){ return new MyInterfaceImpl(parent); }
  16. };
To copy to clipboard, switch view to plain text mode