PySide 6.7.3 (Mac): Missing icons in menus and context menus
-
wrote on 22 Oct 2024, 13:04 last edited by bohning
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.
-
wrote on 29 Oct 2024, 09:11 last edited by
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 ?
-
wrote on 22 Oct 2024, 16:48 last edited by
-
wrote on 22 Oct 2024, 17:17 last edited by
-
Can you provide a minimal project that shows this issue ?
-
wrote on 22 Oct 2024, 19:39 last edited by
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())
-
wrote on 29 Oct 2024, 08:54 last edited by
I get the exact same issue (missing icons in menus), without PyQt, but with Qt 6.7.3 in any QWidget based application, on macOS. Using Qt 6.7.2 the menu icons are visible.
-
wrote on 29 Oct 2024, 09:11 last edited by
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." -
6/10