1 year ago
#71735
Z T
PySide6 tray icon's menu background color disappears in macOS Monterey
I have a small PySide6 app and I created a Tray icon. When the icon is clicked I show a menu where one of the menu option's background is set to red:
self.context_menu = QtWidgets.QMenu()
trayMenu = QLabel("Test Menu")
trayMenu.setAlignment(QtGui.Qt.AlignCenter)
trayMenu.setStyleSheet("background:red;color:white;font-weight:bold;")
trayMenu.setMinimumSize(width, height)
trayMenu.setMaximumSize(width, height)
trayAction = QWidgetAction(self)
trayAction.setText("Test Menu")
trayAction.setDefaultWidget(trayMenu)
self.context_menu.addAction(trayAction)
self.tray_icon = QSystemTrayIcon()
self.tray_icon.setIcon(icon)
self.tray_icon.setContextMenu(self.context_menu)
The problem is when the menu appears I can see the background color as red for like 50ms so it just flashes a little bit of red background and the background color changes back to the original macOS menu background, while the label is bold and white as per the provided css. The same code works perfectly on Windows.
Using background-color:red; has the same effect.
Any idea what I can try?
macos
pyside
pyside6
0 Answers
Your Answer