title: How to handle PyQt5 close event when user closes window?
body: <p>I've basically just designed a quick UI in Qt Designer and converted it to python code. I can't find anywhere online on how to handle the <code>closeEvent()</code> for the converted code that QtDesigner gives me with a class that inherits from <code>object</code>. Any help would be appreciated.
  Here is the set up code (Haven't included specific code for each GUI element as I don't think that should be necessasry... Just want to reduce clutter... Please let me know if you need the whole code):</p>
  <pre><code>class Ui_MainWindow(object):
      def setupUi(self, MainWindow):
          MainWindow.setObjectName(&quot;MainWindow&quot;)
          MainWindow.resize(789, 440)
          self.centralwidget = QtWidgets.QWidget(MainWindow)
          self.centralwidget.setObjectName(&quot;centralwidget&quot;)
          # more set up code...
      def retranslateUi(self, MainWindow):
          #translateUi stuff
  </code></pre>