title: Unable to connect signal to a function inside main()
body: <p>I am aware that to use the signals and slots mechanism of Qt inside a class, the class must include the <code>Q_OBJECT</code> macro, but I am attempting to use signals and slots in <code>main()</code>, without using any class.</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QWidget&gt;
  #include &lt;QTextEdit&gt;
  #include &lt;QtGui&gt;
  
  void saveText();
  
  int main(int argv, char **args)
   {
      QApplication app(argv, args);
      QTextEdit textEdit;
      QPushButton saveButton("Save!");
      QPushButton exitButton("Exit!");
      QObject::connect(&amp;exitButton,SIGNAL(clicked()),qApp,SLOT(quit()));
      QObject::connect(&amp;saveButton,SIGNAL(clicked()),qApp,SLOT(saveText()));
  
      QVBoxLayout vlyt;
      vlyt.addWidget(&amp;textEdit);
      vlyt.addWidget(&amp;exitButton);
      vlyt.addWidget(&amp;saveButton);
  
      QWidget mainWindow;
      mainWindow.setLayout(&amp;vlyt);
      mainWindow.show();
  
      return app.exec();
  }
  
  void saveText()
  {
      exit(0);
  }
  </code></pre>
  
  <p>Here is the GUI window generated:</p>
  
  <p><img src="https://i.stack.imgur.com/puLqj.png" alt="GUI window"> </p>
  
  <p>From the above code, the exit button is connected to <code>quit()</code>, which is a Qt function, when clicked it works. The save button assigned to the function <code>saveText()</code>, is configured to exit, but does not do so.</p>
  
  <p>Please tell me where I have gone wrong in understanding signals and slots in Qt.</p>