title: Qt Auto Connect New Object's Signal to Existing Slot
body: <p>I have a simple object library that will be used for storing additional data about variables. As I create each object (to be used as variable), I would like to maintain a QList of these objects. Is there a way to automatically connect all of the newly created object's signals to one slot. The slot belongs to an object within my application. </p>
  
  <p><strong>Object Header</strong> <em>ezbool.h</em></p>
  
  <pre><code>class EZBool : public QObject
  {
      Q_OBJECT
  public:
      explicit EZBool(QObject *parent = 0);
      EZBool(QString boolName, bool initialValue, IOTYPE type);   
      //Removed Member Functions      
  signals:
      void localEZBool_Created(EZBool *me);
  private:
      QString name;
      bool value;
      IOTYPE ioType;
  };
  </code></pre>
  
  <p><strong>Object Constructor</strong> <em>ezbool.cpp</em></p>
  
  <pre><code>EZBool::EZBool(QString boolName, bool initialValue, IOTYPE type)
  {
      name = boolName;
      value = initialValue;
      ioType = type;
      emit localEZBool_Created(this);
  }
  </code></pre>
  
  <p><strong>Slot Implementation</strong> <em>fbtest.cpp</em></p>
  
  <pre><code>void TestFB::on_localEZBool_Created(EZBool *newVar)
  {
      qDebug() &lt;&lt; "Auto Connect worked??";
      //Handle new variable by adding to QList
  }
  </code></pre>
  
  <p>Objects are created in the following manner within <em>fbtest.cpp</em>:</p>
  
  <pre><code>void TestFB::initialize()
  {
      mpOnCmd     = new EZBool("MpOnCmd", false, IO_INPUT);
      zeroSpeed   = new EZBool("ZeroSpeed", false, IO_INPUT);
  
  }
  </code></pre>
  
  <p>I have tried matching Qt's auto connect feature, but no luck. The auto connect ability was referenced from the following:</p>
  
  <p><a href="http://qtway.blogspot.no/2010/08/automatic-connections-using-qt-signals.html" rel="nofollow noreferrer">Automatic Connections</a></p>
  
  <p><a href="http://qt-project.org/forums/viewthread/4904" rel="nofollow noreferrer">Qt Project Forums</a></p>
  
  <p>I do not want to manually connect every signal after instantiating each new object. In the following manner:</p>
  
  <pre><code>connect(ezBool, SIGNAL(localEZBool_Created(EZBool*)),
          this, SLOT(on_localEZBool_Created(EZBool*)));
  </code></pre>
  
  <p>Does anyone have any recommendations or suggestions? Thank you!</p>