title: Interface in C++ for Qt
body: <p>My question is , can my interface inherit from QObject and how to do that  ? Well , i know that interfaces in C++ are simply classes that contains only virtual methods , and normally a class can inherit from a superclass. But if i do so  i get an error due to ambiguous QObject references. I need to inherit QObject to add signals /slot feature to my plugins.</p>
  
  <p>My interface </p>
  
  <pre><code>#ifndef LABELINTERFACE_H
  #define LABELINTERFACE_H
  
  #include &lt;QLabel&gt;
  #include &lt;QObject&gt;
  
  class LabelInterface : public QObject {
  
  public :
  
      virtual ~LabelInterface() {}
      virtual QLabel* newLabel() = 0;
  
  public slots:
      virtual void setLabelText() = 0;
  };
  
  Q_DECLARE_INTERFACE (LabelInterface,"com.stefan.Plugin.LabelInterface/1.0")
  
  #endif // LABELINTERFACE_H
  </code></pre>
  
  <p>Plugin header file </p>
  
  <pre><code>#ifndef LABELPLUGIN_H
  #define LABELPLUGIN_H
  
  #include "labelinterface.h"
  
  class LabelPlugin : public LabelInterface
  
  {
      Q_OBJECT
      Q_INTERFACES(LabelInterface)
  
  public:
  
      QLabel* label;
      QLabel* newLabel();
       LabelPlugin() {}
      ~LabelPlugin() {}
  
  public slots:
      void setTextForLabel();
  };
  
  #endif // LABELPLUGIN_H
  </code></pre>
  
  <p>Implementation file </p>
  
  <pre><code>#include &lt;QtGui&gt;
  #include "labelplugin.h"
  
  QLabel* LabelPlugin::newLabel() {
  
      label = new QLabel("This plugin works");
  
      return label;
  }
  
  void LabelPlugin::setTextForLabel() {
  
      label-&gt;setText("This plugin works fine");
  
  }
  
  // Exporta plugin-ul
  Q_EXPORT_PLUGIN2 (labelplugin,LabelPlugin)
  </code></pre>
  
  <p>I get error</p>
  
  <pre><code>labelplugin.cpp:18: error: cannot allocate an object of abstract type ‘LabelPlugin’
  </code></pre>