PDA

View Full Version : Help on QTabBar colors



smacchia
6th March 2007, 16:09
I need to be able to set the colors (via use of QPalette) of the tabs in a QTabBar (or the tab bar in a QTabWidget) individually. I can't seem to find a simple way to do this, short of creating a custom QTabBar.

Does anyone know if there is a way to do this?

Thanks in advance,
Susan

smacchia
16th March 2007, 14:09
Well I figured out how to do this in case anyone is interested. The QStyle (derivations) color the tabs using QPalette::Window (& WindowText) for the current tab and QPalette::Button (& ButtonText) for the non-current (selectable) tabs.

So, you need to derive from QTabWidget, so that you can get access to the protected tabBar() method. Then you can set the palette colors for these and applying it to the QTabBar* instance returned by ::tabBar().

Hope this helps anyone who is customizing the colors of the tabs...

tferreira
15th May 2012, 16:48
Does that allow you to set a different background color for each tab?