Reputation: 4607
I have a toolbar with multiple toolbuttons on it, I have tried to apply a style to an individual button with:
QToolButton#button_name
{
border: 3px solid #FF00FF;
}
I thought this would have applied a pink border to just the one button which has the name "button_name" but it does nothing.
i can apply a style to all buttons on the toolbar if i take the "#button_name" off. So im wondering if there is anyway to individual set styles for a specific QToolButton
Cheers
Upvotes: 3
Views: 2159
Reputation: 18524
You should change objectName
of needed widget, not QAction
. You can get this widget with widgetForAction()
method. For example:
QToolBar tool;
QAction * foo = new QAction("foo",&tool);
QAction * bar = new QAction("bar",&tool);
QAction * baz = new QAction("baz",&tool);
tool.addAction(foo);
tool.addAction(bar);
tool.addAction(baz);
tool.widgetForAction(bar)->setObjectName("unique");
tool.show();
qApp->setStyleSheet("QToolButton#unique{border: 3px solid #FF00FF;}");
Result:
Upvotes: 4