我正在使用TrayIcon,我已经添加了一个“退出”QAction,现在,我想在TrayIcon菜单中单击退出时执行某个功能。下面是我的代码有:PyQt - 连接QAction功能
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)