Change QAction Icon in StyleSheet?
I have read some things, like I've seen some things,
I have a QToolBar and QActions with certain icons, i would deign to change these within the .QSS (stylesheet), however it appears that a QAction is not a widget,
so is there no way to access the QAction icon to change it within a style sheet? and perhaps, without getting to cray, would it be feasible and/or recommended to perhaps set up a function to manually change the icons upon user selection of a stylesheet? Your thoughts?
Hi and welcome to devnet,
You can style the QToolButton that will be generated from your QAction. You can give it an object name and use that in your style sheet.
Hope it helps
could you give me an example? I have been able to successfully change the color of the QAction buttons on the toolbar, however, they all change. this is not helpful when trying to do specific ones.
I have tried directly calling the names of the QActions objects in the .qss file, but to no avail. I don't understand what you mean by setting an object name to the QAction button though.
Did you try with an ID Selection like shown in this page ?
Yes, of course, I promise you it does not work.
I know that I can change the icon in code behind, but I wanted to keep it all in the .qss file,
I have tried to call its name, call it as a property of QToolBar, I have read that it is not possible because a QAction is not a widget and even though it creates a button, it is only as an ancillary ToolBar property, which can only be changed on a macro scale, i.e. all icons can be substituted or no icons, all QAction buttons on a toolbar can have their color changed, but it cannot be a single button, but all buttons.
I'm just trying to get the official word on this. Everything I tested failed outside of setting up some sort of key and trying to call it from the .qss, but that did not seem to be plausible.
Did you put the ID on the button created from your action ?