我正在使用一个TrayIcon,我已经添加了一个"退出"QAction,现在,当点击TrayIcon菜单中的退出时,我想执行某个特定的函数。这里是我拥有的代码:
class TrayIcon(QSystemTrayIcon):
"""
Displays a system tray icon
"""
def __init__(self, interface: Interface) -> 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)