[PyQt] Tab labels not shown correctly

Davide Liessi davide.liessi at gmail.com
Mon Mar 9 12:15:44 GMT 2020


Il giorno lun 9 mar 2020 alle ore 13:03 Davide Liessi
<davide.liessi at gmail.com> ha scritto:
> I tried both
> win.tabBar.setStyleSheet("padding: 0px 0px 0px 0px")
> and
> mainwindow.setStyleSheet("padding: 0px 0px 0px 0px")
> (and with 1px as well), but there was no difference.

(I'm sorry, I meant mainwidget instead of mainwindow there.)

I found https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar.
I tried the following and they both seemed to work:
win.tabBar.setStyleSheet("QTabBar::tab { padding: 2px }")
mainwidget.setStyleSheet("QTabBar::tab { padding: 2px }")

However, when adding more tabs, only the selected tabs had the correct
size, while the unselected ones were too small, with text bleeding
from the edges.
Moreover, the color changed as well (no blue highlighting of selected
tab anymore).
Any ideas?


More information about the PyQt mailing list