title: Qt C++ connect QPushButton click
body: <p>I have just started developing using QtGUI and I have checked out some tutorials and documentation, and by what I've read this should work.</p>
  
  <pre><code>#define CONNECT QObject::connect
  
  void test();
  QPushButton *lpTestBtn;
  int main(int argc, char *argv[])
  {
     QApplication a(argc, argv);
     QtProject w;
     w.show();
  
     lpTestBtn = w.window()-&gt;findChild&lt;QPushButton*&gt;("TestBtn");
     CONNECT(lpTestBtn, SIGNAL(clicked()),qApp,SLOT(test()));
  
     return a.exec();
  }
  
  void test()
  {
      lpTestBtn-&gt;setText("Hi");
  }
  </code></pre>
  
  <p>But test() never gets called. Also, lpTestBtn is not null and is found correctly.</p>
  
  <p>I have tried the following changes</p>
  
  <pre><code>CONNECT(lpTestBtn, SIGNAL(clicked()),qApp-&gt;activeWindow(),SLOT(test()));
  
  CONNECT(lpTestBtn, SIGNAL(clicked()),w.window(),SLOT(test()));
  </code></pre>
  
  <p>I know I can just do QtProject::on_TestBtn_clicked(); but I'd like to get it working using CONNECT,SIGNAL and SLOT.</p>