title: Undefined reference to class::slot in Qt/C++
body: <p>I came across an error which says I have an undefined reference to my slot.
  The relevant section from my header file is:</p>
  
  <pre><code>  class Window : public QWidget   {
       Q_OBJECT
       .....    public slots:
       void quit():
       ........... }
  </code></pre>
  
  <p>and from my implementation file is:</p>
  
  <p>Window::Window()     {
        ......
        //Setting up Pushbutton</p>
  
  <pre><code>  button1 = new QPushButton("Quit");
    button1-&gt;show();
  
   //Connecting
   connect(button1, SIGNAL(clicked()), this,  SLOT(quit())); 
   ....... }
  </code></pre>
  
  <p>The error I get on compilation is: </p>
  
  <blockquote>
    <p>undefined reference to `Window::quit()'</p>
  </blockquote>
  
  <p>However, I believed that my use of 'this' in the connection code would make a defined reference to this. It has for my previous signals and slots when making connections. Also, I have used the 'quit' slot in a main window application - so I know that's a relevant slot to use. </p>
  
  <p>From searching the forums, the problem is usually resolved by the use of 'this' in the connection part of the code - so I haven't been able to find a solution.</p>