title: Define signals and slots inside main.cpp
body: <p>I wrote a little program with a my own class within the main.cpp. Here the code:</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QPushButton&gt;
  #include &lt;QLabel&gt;
  
  class MyWidget : public QWidget {
      //Q_OBJECT
  public:
      MyWidget(QWidget* parent = 0);
      QLabel* label;
      QString string;
  
  signals:
  public slots:
      void setTextLabel();
  
  };
  
  void MyWidget::setTextLabel() {
      label-&gt;setText("Test");
  }
  
  
  MyWidget::MyWidget(QWidget* parent) 
       : QWidget(parent) {
  
  }
  
  int main(int argc, char** argv) {
      QApplication app(argc, argv);
  
      MyWidget widget;
      widget.show();
  
      return app.exec();
  }
  </code></pre>
  
  <p>it seems work but not "completely". My slot doens't work. I suppose i have to put Q_OBJECT. BUT, doing so, I got a list of errors, like this:</p>
  
  <pre><code>undefined reference to `vtable for MyWidget'
  ........................................
  collect2: error: ld returned 1 exit status
  make: *** [mywidget] Error 1
  </code></pre>
  
  <p>I can I manage that? Where the problem?</p>