I know, that this question has been discussed here and on other sites, but there has not been a really solution yet, although I think, that I'm not the only one with this problem:
How can I individually and dynamically access a single tab (not its content resp. the widget in the tab) for styling purposes, such as changing the background color or adding graphical effects to it? An application could be to notify the user, that a tab requires his attention, by letting it flash in another color (like in the windows task bar, if a window wants to get focus). There is a function to change the text color, why not more? Stylesheets can be used to access the selected, the first etc. tab, but not a specific one by its index. Some people talked about subclassing QTabBar, but I do not know, how this will lead to the desired solution. Is there any possibility to achieve this and if yes, please provide an example.
In order to access each style of each
QTabBar
tab you must overwrite thepaintEvent()
method of it.The generic way of doing this should have the following structure:
In this part I show an example of how to create a QTabWidget where it shows a tab that blinks and only ends the blinking if we click on that tab
TabBarAlert:
TabWidgetAlert:
The complete example can be found at the following link