QSS QTabBar text-align does not work
-
I try (font-weigth: works, but text-align: does not work):
@QTabBar::tab:text{
font-weight:bold;
text-align:left;
}@I try, but it was also not working:
@QTabBar::tab {
font-weight:bold;
text-align:left;
}@My QTabWidget:
@<item>
<widget class="QTabWidget" name="tabWidget">
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>@I also have not found any "property" (<property name="...">) that aligns the text.
how to use the "QSS" to align the text of the tabs (QTabBar/QTabWidget) ?
-
i just checked (in Qt4): tabs don't support text alignment directly.
The only possibility you can try is to set the text-alignment on the QTabBar instead of it's ::tab selectors. -
I try, but not working.
@ QTabBar{
text-align:left;
}@what do I do? Thanks.
-
it was an idea. If this isn't working either i am afraid it isn't possible at all.
Nevertheless you can do the painting yourself as a last resort.
See QTabBar::paintEvent() for more details.
And idea to do so would be to pass an style option object without the text and let the tabs be drawn by Qt. Then find out the "content rects" for each tab and draw your aligned text in there.But if its the first time you are doing this it will be a hard work i guess.
-
Seems like a great idea, I'll try, even though I have not done this before I will not be so complex.
But what is odd is to have a selector (QSS) to do that.
I'll try
-
[quote author="Guilherme Nascimento" date="1386951146"]
But what is odd is to have a selector (QSS) to do that.[/quote]
For that simply define a (styleable) property which you then use in your painting code.