PDA

View Full Version : How to highlight a character of tabText of the TabWidget?



aaron
1st September 2009, 03:30
Dear all,
I want to highlight a character of the text of the QTabWidget,for example, the tabText is "Display Tab" , and I want to change it to "Diaplay Tab *" , but how to do it ?
Thanks!

wysota
1st September 2009, 07:07
There is no straightforward way to do that. You'd have to subclass QTabBar, reimplement tab drawing routines and then subclass QTabWidget and use your new TabBar.

aamer4yu
1st September 2009, 07:09
Am not sure if it will work...but you can try using rich text while setting the tab text..
something like -
setTabText(index,"Display Tab <red> *</red>");

aaron
1st September 2009, 07:54
Dear ,
Thanks for your advice.
Wysota's idea should meet my request, but my Qt's version is 4.3, so some function like "setTabButton() ..." can not support.
I will try aamer4yu's idea. Thanks again.

wysota
1st September 2009, 07:56
I was not talking about setTabButton. I was talking about QTabWidget::setTabBar(). Rich text doesn't work on tabs so you can safely skip trying it.

aaron
2nd September 2009, 04:00
Dear wysota,
According to your advice, I have done it, thanks for your support