title: PyQt - Connect QAction to function
body: <p>I am using a TrayIcon, I have added a "Exit" QAction, and now, I want to execute a certain function when clicking Exit in the TrayIcon menu. Here is the code I have : </p>
  
  <pre><code>class TrayIcon(QSystemTrayIcon):
      """
      Displays a system tray icon
      """
  
      def __init__(self, interface: Interface) -&gt; None:
          """
          Constructor
          :param interface: Interface to show when the tray icon is clicked
          """
          super().__init__(QIcon(resource_filename("ezstorage.resources.img.tray_icon", "folder.png")))
          self.interface = interface
          self.setVisible(True)
          self.show()
          self.activated.connect(self.clicked)
          menu = QMenu()
          action = QAction("Exit")
          menu.addAction(action)
          self.setContextMenu(menu)
  </code></pre>