[Qt-interest] QTabBar background colors

Benjamin ikipou at gmail.com
Thu Dec 11 22:24:23 CET 2008


Yes, if you need a color for each tab, QPalette is not a solution.
I think you could use the same trick already discussed about the color of a
context menu.

You subclass QStyle, override drawControl, and put the right color when the
tab with the right text is being drawn.

good luck,
Benjamin

2008/12/11 Diana Coppenbarger <dcop at lle.rochester.edu>

> But how do you tell it which tab to change the color of?  I don't think I
> have access to the individual tabs to use setPalette().  Each tab needs to
> be a different color.  If I call setPalette() on the widgets used in
> addTab(), the background of the whole page changes, but not the tab
> associated with it.  I can get the geometry of a tab by using tabRect(), but
> I'm not sure how to change the color using that value, if it's even
> possible.
>
>
> On Dec 11, 2008, at 3:34 PM, Benjamin wrote:
>
> Hi,
>
> Have you tried to change the color of the Palette? (QWidget::setPalette())?
>
> Benjamin
>
> 2008/12/11 Diana Coppenbarger <dcop at lle.rochester.edu>
>
>> I am trying to figure out how the change the background colors on the
>> tabs for a QTabWidget.  I have created my own class, inheriting from
>> QTabWidget to be able to get access to the QTabBar.  I can change the
>> text color by using tabBar()->setTabTextColor(QColor(Qt::red));, but I
>> really want to be able to change the *background* color of just the
>> tab.  I am using Qt 4.3.  Any thoughts?
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20081211/87895dc4/attachment.html 


More information about the Qt-interest-old mailing list