title: C++ Qt signal and slot not firing
body: <p>I am having difficulty in my Qt program with connecting button signals to my slots. My code is:</p>
  
  <p>Main.cpp</p>
  
  <pre><code>#include &lt;QtGui/QApplication&gt;
  #include "MainWidget.h"
  
  int main(int argc, char *argv[])
  {
      QApplication app(argc, argv);
  
      MainWidget mainWidget;
      mainWidget.show();
  
      return app.exec();
  }
  </code></pre>
  
  <p>MainWidget.h</p>
  
  <pre><code>#ifndef MAINWIDGET_H
  #define MAINWIDGET_H
  
  #include &lt;QWidget&gt;
  
  class MainWidget : public QWidget
  {
  public:
      MainWidget();
  
  public slots:
      void bAdvice_clicked();
      void bWeather_clicked();
      void bNextMeeting_clicked();
      void bQuit_clicked();
  };
  
  #endif // MAINWIDGET_H
  </code></pre>
  
  <p>MainWidget.cpp</p>
  
  <pre><code>#include "MainWidget.h"
  #include &lt;QMessageBox&gt;
  #include &lt;QPushButton&gt;
  #include &lt;QTextEdit&gt;
  #include &lt;QVBoxLayout&gt;
  
  MainWidget::MainWidget()
  {
      QLayout *layout = new QVBoxLayout();
      this-&gt;setLayout(layout);
  
      QTextEdit *message = new QTextEdit();
      layout-&gt;addWidget(message);
  
      QPushButton *bAdvice = new QPushButton("Advice");
      connect(bAdvice, SIGNAL(clicked()), this, SLOT(bAdvice_clicked()));
      layout-&gt;addWidget(bAdvice);
  
      QPushButton *bWeather = new QPushButton("Weather");
      connect(bWeather, SIGNAL(clicked()), this, SLOT(bWeather_clicked()));
      layout-&gt;addWidget(bWeather);
  
      QPushButton *bNextMeeting = new QPushButton("Next Meeting");
      connect(bNextMeeting, SIGNAL(clicked()), this, SLOT(bNextMeeting_clicked()));
      layout-&gt;addWidget(bNextMeeting);
  
      QPushButton *bQuit = new QPushButton("Quit");
      connect(bQuit, SIGNAL(clicked()), this, SLOT(bQuit_clicked()));
      layout-&gt;addWidget(bQuit);
  }
  
  void MainWidget::bAdvice_clicked()
  {
  }
  
  void MainWidget::bWeather_clicked()
  {
  }
  
  void MainWidget::bNextMeeting_clicked()
  {
      QMessageBox::information(this, "Next Meeting", "Today", QMessageBox::Ok);
  }
  
  void MainWidget::bQuit_clicked()
  {
      this-&gt;close();
  }
  </code></pre>
  
  <p>The program outputs the following:</p>
  
  <pre><code>Starting C:\Users\Sameer\Documents\PartAQuestion2\debug\PartAQuestion2.exe...
  Object::connect: No such slot QWidget::bAdvice_clicked() in MainWidget.cpp:16
  Object::connect: No such slot QWidget::bWeather_clicked() in MainWidget.cpp:20
  Object::connect: No such slot QWidget::bNextMeeting_clicked() in MainWidget.cpp:24
  Object::connect: No such slot QWidget::bQuit_clicked() in MainWidget.cpp:28
  
  C:\Users\Sameer\Documents\PartAQuestion2\debug\PartAQuestion2.exe exited with code 0
  </code></pre>
  
  <p>The code seems right, no compiler warnings. Just this output at runtime. But it looks like I hooked the signals and slots up correctly.</p>