0

I have added 3 QActions to one QToolButton.

And this QToolButton is in a QToolBar.

like this:

 toolButton = new QToolButton();
 action1 = new QAction(tr("Action 1"),this); 
 action1->setObjectName("obj_action1");
 //action1->setIcon(QIcon(":/images/icons/action1.png")); 

 action2 = new QAction(tr("Action 2"),this); 
 action2->setObjectName("obj_action2");
 //action2 ->setIcon(QIcon(":/images/icons/action2.png")); 

 action3 = new QAction(tr("Action 3"),this); 
 action3->setObjectName("obj_action3");
 //action3 ->setIcon(QIcon(":/images/icons/action3.png")); 

 toolButton->setDefaultAction(action1); 
 toolButton->addAction(action2); 
 toolButton->addAction(action3); 

 toolButton->setPopupMode(QToolButton::InstantPopup); 

 ui->toolBar->addWidget(toolButton);  

Now i want to set icons for each QAction by Style sheet.

How can i set icons with QT Style sheet in this case?

jung
  • 557
  • 2
  • 4
  • 16
  • stylesheets only apply to widgets, and `QAction` isn't a widget. Also, the only real hook into icons is the qss `image` property, and doesn't always do what you'd hope it would do. – Nicolas Holthaus May 04 '16 at 14:48
  • @Nocolas / i understand. Is there any possiblility to get the parent (or container) Widget of QAction Icons? In QT Document, there is QAction::setIcons function. This means, if a QAction get a icon through QAction::setIcons function, then it must create a parent or container Widget for this icon. So.. The Question is now... How can i get this parent or container Widget for this icon? – jung May 06 '16 at 07:24

0 Answers0