之后出现的
如何修复以下错误?
from PyQt5 import Qt
import sys
app = Qt.QApplication(sys.argv)
systemtray_icon = Qt.QSystemTrayIcon(app,
Qt.QIcon(r'C:UserspsivabalDesktopo-SWAMI-VIVEKANANDA-facebook.jpg'))
systemtray_icon.show()
systemtray_icon.showMessage('Title', 'Content')
错误:
Traceback (most recent call last):
File "C:/Users/psivabal/Desktop/Udacity/My_Examples/Cricket Score trying/TRial.py", line 4, in <module>
systemtray_icon = Qt.QSystemTrayIcon(app, Qt.QIcon(r'C:UserspsivabalDesktopo-SWAMI-VIVEKANANDA-facebook.jpg'))
TypeError: arguments did not match any overloaded call:
QSystemTrayIcon(parent: QObject = None): too many arguments
QSystemTrayIcon(QIcon, parent: QObject = None): argument 1 has unexpected type 'QApplication'
根据文档,您应该实例化qsystemtrayicon如下:
Qt.QSystemTrayIcon(Qt.QIcon(r'icon.jpg'), app)
提示:qObject是在图标实例