title: Qt: Access Widget from main function and implement exit button
body: <p>I want to implement an exit button in my application, which has the following setup:
  I have a main function which looks like this:</p>
  
  <pre><code>QApplication a(argc, argv);
  MainWindow w;
  
  w.show();
  
  return a.exec();
  </code></pre>
  
  <p>I also have a mainWindow function which has been generated by the QT Creator IDE. <br>
  I design the GUI with the Qt Designer and when I want a pushbutton to do something when clicked, I use a function like this:</p>
  
  <pre><code>void on_selection_clicked();
  </code></pre>
  
  <p>I hope the setup is now sufficiently described.<br>
  Now to my problem: I want to implement a button, which, when clicked, terminates the window and the application. I first tried implementing this in a function like this:</p>
  
  <pre><code>void on_exit_clicked();
  </code></pre>
  
  <p>But I don't know that to to here.<br>
  Then I heard of a aproach via <code>QObject::connect</code>, but I have two questions:<br>
  1.) Where should I put this? In the main function?<br> 2.) can I access the object simply via the object name given in the QT Designer?</p>