PySide 6.7.3 (Mac): Missing icons in menus and context menus
-
I am using Pyside 6.7.3 and have several actions with icons attached to them, e.g.
However, the icons are missing in the app, both in the menu as well as in the context menu:
This only happens on Mac, the icons are not missing when running the app on Windows. This also happens with 6.8.0 and I think also with 6.8.0.1.
-
I think I now found it... looks like a feature. See Release Notes Qt 6.7.3:
"a2aa1f81a81 Determine Qt::AA_DontShowIconsInMenus default value based on platform The default value of Qt::AA_DontShowIconsInMenus is now determined based on the platform. On macOS icons will not show by default. To override, use QAction.iconVisibleInMenu for individual menu actions, or set Qt::AA_DontShowIconsInMenus to false." -
Hi,
Where are you loading the images from ?
-
Can you provide a minimal project that shows this issue ?
-
It also fails if the icon files are used directly, without the resources.qrc.
import sys from PySide6.QtGui import QAction, QIcon from PySide6.QtWidgets import QApplication, QMainWindow, QMenu class MainWindow(QMainWindow): def __init__(self) -> None: super().__init__() menu_bar = self.menuBar() file_menu = QMenu("&File", self) menu_bar.addMenu(file_menu) new_action = QAction(QIcon("./src/new.png"), "New", self) open_action = QAction(QIcon("./src/open.png"), "Open", self) save_action = QAction(QIcon("./src/save.png"), "Save", self) file_menu.addAction(new_action) file_menu.addAction(open_action) file_menu.addAction(save_action) if __name__ == "__main__": app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec())
works with 6.7.2:
but fails with 6.7.3:
-
I think I now found it... looks like a feature. See Release Notes Qt 6.7.3:
"a2aa1f81a81 Determine Qt::AA_DontShowIconsInMenus default value based on platform The default value of Qt::AA_DontShowIconsInMenus is now determined based on the platform. On macOS icons will not show by default. To override, use QAction.iconVisibleInMenu for individual menu actions, or set Qt::AA_DontShowIconsInMenus to false." -
Thanks for the feedback !
And sorry for the late reply, I missed your answer. Your deduction looks correct.
-
I think I now found it... looks like a feature. See Release Notes Qt 6.7.3:
"a2aa1f81a81 Determine Qt::AA_DontShowIconsInMenus default value based on platform The default value of Qt::AA_DontShowIconsInMenus is now determined based on the platform. On macOS icons will not show by default. To override, use QAction.iconVisibleInMenu for individual menu actions, or set Qt::AA_DontShowIconsInMenus to false." -