2

how can i set an Icon for a QAction in QMenu through Stylesheet?

for example:

QMenu* menu = new QMenu();

QAction* action1= new QAction();
QACtion* action2= new QAction();

menu->addAction(action1);
menu->addAction(action2);

now i want to set different icon for action1 and action2 with QT Stylesheet.

Is it possible with Stylesheet?

jung
  • 557
  • 2
  • 4
  • 16

1 Answers1

0

Stylesheets only apply to widgets.

Qt Style Sheets are a powerful mechanism that allows you to customize the appearance of widgets, in addition to what is already possible by subclassing QStyle.

QAction is not a widget, thus you can't add an icon to a QAction via the style sheets. However, you could probably have a shot with QActionWidget and for example a QLabel, even if it can be tricky.

IAmInPLS
  • 4,051
  • 4
  • 24
  • 57