QTabWidget set title font of only one tab
I've created a chat program with an Interface using QTabWidget
. If there's an u开发者_如何学Pythonpdate in a tab i want to set the tabs title font to a bold font. With QTabWidget::font i can only set the font of the titles of all tabs.
Unfortunately, you can only access the text itself. The font of the text is not exposed in the QTabBar of the QTabWidget. Perhaps changing the color of the tab would suffice? Otherwise, you'd have to override the painting algorithms, which probably would prove to be cumbersome. In Qt 3 it was possible accessing the QTab
with tabAt(int index)
but, unfortunately, they removed that.
You can use QTabBar::setTabTextColor() method, like this:
QTabBar* bar=tagWidget->tabBar();
bar->setTabTextColor(index, Qt::blue);
Haven't Qt close to me now, but the idea is that you should try to set the font for particular page item of the tab widget. Try something like this:
yourTabWidget.currentWidget()->setFont(/*bold font*/);
精彩评论