Programatically make a tab's text bold
-
wrote on 3 Apr 2018, 20:09 last edited by
How can I programatically make a tab's text bold?
I'm looking to notify the user that they need to look at it.
-
Hi
Perhaps you could use a stylesheet and change the current tab to highlight it
QTabBar::tab:selected. { font-weight: bold; } -
wrote on 3 Apr 2018, 20:41 last edited by
I need to specifically choose which tab to make bold, and it can't be just the currently selected - it could be unselected too. Any ideas?
-
I need to specifically choose which tab to make bold, and it can't be just the currently selected - it could be unselected too. Any ideas?
@Vadi2
since its random tabs, not sure you can target that with stylesheet.
I was wondering if text color could work, so instead of Bold, then some color ?
http://doc.qt.io/qt-5/qtabbar.html#setTabTextColor
http://doc.qt.io/qt-5/qtabwidget.html#tabBar -
wrote on 3 Apr 2018, 20:57 last edited by
A colour is different because the user could have a custom theme that conflicts. I'd really like it bold - like Firefox can and so on.
-
can the tabText be HTML? this would allow any kind of formatting, including bold.
-
wrote on 4 Apr 2018, 05:09 last edited by
I tried
setTabText(i, "<b>testing</b>");
and it did not work. -
How can I programatically make a tab's text bold?
I'm looking to notify the user that they need to look at it.
@Vadi2
mmh, haven't tried it, but I think, you can potentially set an Icon, that spans the whole tab width, that would give the illusion a modified Tab-Text ?Edit:
Google search, brought me to this old forum post
@SGaist and @Goutye
had the right idea, re-implement paintEvent seems to be agood (the best?) option -
wrote on 4 Apr 2018, 11:17 last edited by
Hi,
I supposed that you have a QTabWidget and just wants to change the style of one tab button. Have you tried something like:myTabWigdet->tabBar()->tabButton(myIndex, 0)->setStyleSheet("MyStyle");
-
wrote on 4 Apr 2018, 12:09 last edited by
The tab button (X) is not what I'm looking for - I want to grab the tab itself, not the close button within it :(
-
The tab button (X) is not what I'm looking for - I want to grab the tab itself, not the close button within it :(
-
Using re-implemented paintEvent() is too complicated. Rather, i think using something like QProxyStyle would be a better choice.
@Devopia53 when I read my Interest-Email feed correctly, than the OP has a solution to the problem, with indeed using QProxyStyle. But hasn't updated the topic to solved yet.
since when is re-implemented paintEvent() to complicated? Thats about 20 lines of code to get the desired result, in this case at least.
-
wrote on 6 Apr 2018, 08:35 last edited by
Yep, solved with http://lists.qt-project.org/pipermail/interest/2018-April/029734.html. Thanks everyone.
1/13