I am building a Qt UI in 3dsMax 2018 using PySide2, this ships with Max so is a pretty vanilla setup.
I would like to access some of the existing icon images that Max uses in its UI, but am having trouble accessing them correctly. As an example, lets look at the humble Undo icon.
The Autodesk docs tell me that this icon exists, that it’s path is “MainUI” and the icon is “Undo” and it’s available in sizes 24, 30, 36 and 48.
https://help.autodesk.com/view/3DSMAX/2018/ENU/?guid=__developer_icon_guide_icon_guide_html
It also tells me that the icons are stored in the “Light.rcc” and “Dark.rcc” files on disc. These are compiled Qt resource files and not text readable like the .qrc files. These files are found here …
C:\Program Files\Autodesk\3ds Max 2018\UI_ln
I can access the icon as expected though Maxscript using the path and icon name.
rollout test_icons “Testing icons” (
bitmap the_icon iconName:“MainUI/Undo”
)
createDialog test_icons
I can also confirm the path of the icon by using the code below and hovering over the toolbar undo button.
CustomControlsOptions.PrintIconPaths = true
Which gives the following output
Path of this control’s QIcon: [C:\Program Files\Autodesk\3ds Max 2018\UI_LN\IconsDark.rcc] MainUI\Undo
IconSize: 24x24 (native) IconState: off
Available Files: Undo_24.png, Undo_30.png, Undo_36.png, Undo_48.png
However when in Python I am unable to access the icon as I would expect. As a minimal example running in Max:
from MaxPlus import GetQMaxMainWindow from PySide2 import QtCore, QtGui, QtWidgets main_window = GetQMaxMainWindow() window = QtWidgets.QMainWindow(parent=main_window) label = QtWidgets.QLabel(window) undo_button = QtWidgets.QToolButton(window) icon = QtGui.QIcon(":/MainUI/Undo") undo_button.setIcon(icon) layout = QtWidgets.QVBoxLayout(window) layout.addWidget(undo_button) window.setLayout(layout) window.show()