pyqt system tray icon exit when click menu item

前端 未结 1 1599
执笔经年
执笔经年 2021-01-25 23:52

I am new to python and pyqt, I learn them today and write a small system tray demon, it run , but when i click \"about\", and then close the dialog, the app exit. I don\'t know

1条回答
  •  执念已碎
    2021-01-26 00:02

    You can set the application quitOnLastWindowClosed property to False:

    def main():
        app = QtGui.QApplication(sys.argv)
        app.setQuitOnLastWindowClosed(False)
        trayIcon = SystemTrayIcon(QtGui.QIcon("trash.svg"))
        trayIcon.show()
        sys.exit(app.exec_())
    

    0 讨论(0)
提交回复
热议问题