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 do not think this is supported in the current version of Qt (5.4). You can try using a paint event with
QPainter
to draw the text onto the tab in the alignment you want.You could use specific padding and
Qt::AlignLeft
to get this outcome potentially.See this post on the Qt forum for more info - https://forum.qt.io/topic/35405/qss-qtabbar-text-align-does-not-work