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.
Asked
Active
Viewed 2,404 times
2 Answers
8
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

eyllanesc
- 235,170
- 19
- 170
- 241
2
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()
.

Vincent Fourmond
- 3,038
- 1
- 22
- 24