title: Qt Connecting Signal to Slots
body: <p>I have two classes. For simplicity, I'll call them class A and class B. I want to use the <a href="http://qt-project.org/doc/qt-4.8/signalsandslots.html" rel="nofollow">Qt Signals and Slots</a> to link when the functions <code>setXPos()</code> or <code>setYPos()</code> of class <code>A</code> are called to class <code>B</code> that displays an image on a certain position so that the image cna move to the correct coordinates. Here is my code:</p>
  
  <pre><code>class A: public QObject
  {
      Q_OBJECT
  public:
      A();
      void setXPos(int newPos) {xPos = newPos; emit posChanged(xPos, yPos);};
      void setYPos(int newPos) {yPos = newPos; emit posChanged(xPos, yPos);};
  
  signals:
      void posChanged(int x, int y);
  
  private:
      int xPos;
      int yPos;
  };
  
  
  class B : public QObject
  {
      Q_OBJECT
  
  public:
      B(std::shared_ptr&lt;A&gt; classA);
      void changePos(int x, int y);
  
  public slots:
      void posChanged(int x, int y);
  
  private:
      QPixmap image;
      std::shared_ptr&lt;A&gt; classA;
  };
  </code></pre>
  
  <p>So in my <code>B</code> object I want to catch the emit of the <code>posChanged()</code> in class <code>A</code>. You can see in the constructor of <code>B</code> a pointer to <code>A</code> is given, which is stored in class <code>B</code>. So in the constructor I want to do:</p>
  
  <pre><code>B::B(std::shared_ptr&lt;A&gt; classA) : classA(classA)
  {
      QObject::connect(classA, SIGNAL(posChanged(int x, int y)), *this, SLOT(posChanged(int x, int y)));
  }
  </code></pre>
  
  <p>But this gives errors that there is no matching function for my call inside my <code>connect</code>.</p>