title: Qt QMainWindow at Close
body: <p>this may seem like a very simple question, but I want to dump some data whenever the <code>QMainWindow</code> closes, so I used the following piece of code:</p>
  
  <pre><code>QObject::connect(MainWindow.centralwidget, SIGNAL(destroyed()), this, SLOT(close()));
  </code></pre>
  
  <p>But this doesn't seem to make it call <code>close()</code>. Am I doing this wrong?.<br> Isn't the centralwidget suppose to be destroyed?.</p>
  
  <p>Or perhaps the application closes before <code>close()</code> can be called?.</p>
  
  <p>Any other ways of doing it then?</p>