QTabWidget set title font of only one tab
Asked Answered
G

3

7

I've created a chat program with an Interface using QTabWidget. If there's an update 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.

Gingham answered 12/3, 2011 at 11:20 Comment(0)
A
5

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.

Antimissile answered 12/3, 2011 at 12:2 Comment(0)
B
3

You can use QTabBar::setTabTextColor() method, like this:

QTabBar* bar=tagWidget->tabBar();
bar->setTabTextColor(index, Qt::blue);
Biisk answered 25/10, 2011 at 8:1 Comment(0)
H
0

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*/);
Hightest answered 12/3, 2011 at 12:9 Comment(1)
Nope, the currentWidget() accesses the page and not the "text" widget of the tab in question.Antimissile

© 2022 - 2024 — McMap. All rights reserved.