@SGaist
I add en eventfilter to sysTray itself:
import sys
from PySide6.QtCore import QEvent, QObject
from PySide6.QtGui import QAction, QIcon
from PySide6.QtWidgets import QApplication, QMenu, QSystemTrayIcon
class sysTray(QSystemTrayIcon):
def __init__(self, parent=None):
super().__init__(parent)
self.installEventFilter(self)
self.icon = QIcon("icon/meta_running.ico")
self.setIcon(self.icon)
self._toggle_action = QAction("toggle", self)
self._tray_icon_menu = QMenu()
self._tray_icon_menu.addAction(self._toggle_action)
self.setContextMenu(self._tray_icon_menu)
self.show()
def eventFilter(self, watched: QObject, event: QEvent) -> bool:
print(watched, event)
return super().eventFilter(watched, event)
if __name__ == "__main__":
app = QApplication(sys.argv)
tray = sysTray()
sys.exit(app.exec())
When I click the tray it outputs nothing.
And when I right click and move mouse to the context menu it outputs something.
<__main__.sysTray(0x2a07487c970) at 0x000002A075151380> <PySide6.QtCore.QEvent(QEvent::ChildAdded)>
<__main__.sysTray(0x2a07487c970) at 0x000002A075151380> <PySide6.QtCore.QEvent(QEvent::StatusTip)>
I have tried QWidget and everything is OK in Windows 11. I have also tried QSystemTrayIcon in Arch Linux and it is also OK.
No idea what is wrong with it in Windows 11.