title: Signal/Slot interaction for two plugins in Qt
body: <p>So basically i have a little application that loads two plugins and <code>connect</code> them. First plugin after it's loaded it creates a label without any title  which will be added to main window. Second plugin creates an action which will be added to a menu. So my app  need just to load these plugins and to <code>connect</code> them . What i mean by connecting them ? i mean that label plugin contains a slot which will modify label's title , and action plugin has a signal declared. Application should <code>connect</code> action plugin signal with label slot. I do not know how to do it exactly. My guess is that in action plugin class  implementation is to connect custom   signal with a standart signal (triggered). But anyway this ways my app is not working as i expected. How can i make a correct connection in my app for a signal from one plugin and slot from another plugin ??</p>
  
  <p>Here is my code for Label Plugin :</p>
  
  <pre><code>#include "LabelInterface.h"
  
  class LabelPlugin : public LabelInterface {
  
      Q_OBJECT
      Q_INTERFACES(LabelInterface)
  
  public:
      QLabel* label;
      QLabel* newLabel();
       LabelPlugin() {}
      ~LabelPlugin() {}
  
  public slots:
      void setTextforLabel();
  }; 
  
  #include &lt;QtGui&gt;
  #include "LabelPlugin.h"
  
  QLabel* LabelPlugin::newLabel() {
  
      label = new QLabel("");
      return label;
  }
  
  void LabelPlugin::setTextforLabel() {
  
      label-&gt;setText("This plugin works fine");
  }
  
  // Exporta plugin-ul
  Q_EXPORT_PLUGIN2 (labelplugin,LabelPlugin)
  </code></pre>
  
  <p>Action Plugin :</p>
  
  <pre><code>    #include "ActionInterface.h"
  
      class ActionPlugin : public ActionInterface  {
  
          Q_OBJECT
          Q_INTERFACES (ActionInterface)
  
      public :
           QAction* myAction;
           QAction* newAction();
  
          ~ActionPlugin () {}
           ActionPlugin () {}
  
      public slots:
           void send_signal();
  
       signals :
           void pushMyAction();
      };
  
  #include &lt;QtGui&gt;
  #include "ActionPlugin.h"
  
  QAction* ActionPlugin::newAction() {
  
      myAction = new QAction("Show text",this);
  
      return myAction;
  }
  
  void ActionPlugin::send_signal() {
  
      qDebug ()&lt;&lt;"Here";
  
      QAction::connect (this,SIGNAL(pushMyAction()),this,SIGNAL(triggered()));
  }
  
  Q_EXPORT_PLUGIN2 (actionplugin,ActionPlugin)
  </code></pre>
  
  <p>In my app , where i try to load plugins i have :</p>
  
  <pre><code>   foreach (QString fileName, appDir.entryList(QDir::Files)) {
  
          qDebug()&lt;&lt;QString(fileName);
  
          QPluginLoader pluginLoader(appDir.absoluteFilePath(fileName));
  
          QObject* plugin = pluginLoader.instance();
  
           if (plugin) {
  
              ActionInterface* myAction= qobject_cast&lt;ActionInterface*&gt;(plugin);
  
              if (myAction) {
                  action_ = myAction;
                  pluginMenu-&gt;addAction(action_-&gt;newAction());
              }
  
              LabelInterface* myLabel = qobject_cast&lt;LabelInterface*&gt;(plugin);
  
              if (myLabel) {
                  label_=myLabel;
                  layout-&gt;addWidget(label_-&gt;newLabel());
              }
  
              if (action_ &amp;&amp; label_) {
  
                  qDebug()&lt;&lt;"both loaded";
  
                  action_-&gt;send_signal();
                  connect(action_, SIGNAL(pushMyAction()),label_, SLOT(setTextforLabel()));
              }
              else qDebug() &lt;&lt; "seems one plugin is not loaded";
          }
      }
  </code></pre>