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 their attention, by letting it flash in another color (like in 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/first... 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.
If this is possible, how could it be implemented?
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