title: PySide / PyQt detect if user trying to close window
body: <p>is there a way to detect if user trying to close window?
  For example, in Tkinter we can do something like this:</p>
  
  <pre><code>def exit_dialog():
      #do stuff
      pass
  
  root = Tk()
  root.protocol("WM_DELETE_WINDOW", exit_dialog)
  root.mainloop()
  </code></pre>
  
  <p>Thanks.</p>