PDA

View Full Version : QTabWidget style each tab differently



MichaH
4th October 2016, 07:10
Hi everyone,

is it possible to style each tab of a QTabWidget differently while using e.g. the tabindex as the individual tabs are widgets?
The setStyleSheet option only styles the whole QTabBar apart from using different states (: only-one, : first, : last, : middle, : previous-selected, : next-selected, : selected).

Thanks!!

Killian
10th October 2016, 15:45
I had a similar project long ago. QStyleSheets had not been of any use for this since they are pretty limited as you mentioned.

My solution was to subclass from QTabWidget and to extend the paintEvent. There you can react on the current index and so on and draw some colors/gradients/borders as much as you like.

Ginsengelf
11th October 2016, 09:24
Hi, you could try QTabBar::setTabButton and set different widgets for each tab.

Ginsengelf