In my project, I have a QTabWidget with multiple tabs, each having a unique icon. I want the icon to change to a lighter version of the normal icon whenever the tab is selected.
This is simple with stylesheets QTabBar::tab:selected{image: url(image.png);} however the problem is that the stylesheet can't differentiate between each different tab to set the correct icon. There isn't just an 'on' and 'off' icon. There is an 'on' and 'off' icon for 7 different icons.
Sticking with the stylesheet :selected method, I'm trying to find a way to accomplish this with accessibleName. If upon tab creation I set the accessibleName for each tab to an icon type identifier (icon_1, icon_2, icon_3, etc), I could select it later in my stylesheet with QTabBar::[accessibleName=\"icon_1\"]:selected.
However I don't see anything in the documentation that says I can set an accessibleName for each tab. Is this possible? Also, I'm aware I could listen for the currentIndexChanged signal and update the icon without stylesheets, however the actual method of figuring out which icon to use for each tab is quite a bit of work, so it's not ideal to recheck every tab each time the index has changed. Not to mention that the user can have as many tabs open at any given time. Make sense?
Is it possible to set an accessibleName onto a tab? Is there another way to select between different tabs via stylesheets? Thanks for your time.