I have run the menu example from Qt and there are no icons on menus, only text. Most apps (like pcmanfm and caja from Ubuntu) have similar icons, so I suppose they are system-wide and not application specific. How could I put icons in menu items? A code sample would be interesting.
Adding New Icons to Start Menu and Taskbar Program icons can be added from the icons on the desktop or from the Start Menu. To “pin” an icon on the Desktop to your Start Menu put your cursor over the icon and “right click” to bring up the options menu. Then select “Pin to start” to add that icon to the Start Menu.
To obtain the icons of the systems you must use the method QIcon::fromTheme()
Example:
newAct = new QAction(tr("&New"), this);
newAct->setIcon(QIcon::fromTheme("document-new"));
Qt uses as a backend to freedesktop icon, it has a rule in the names, the updated list of them can be found in the following link
The QIcon::fromTheme()
function found in the other answer is unfortunately not portable to Mac or windows. You may have better luck using QStyle::standardIcon()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With