简体   繁体   中英

PyQt4: Change text size and font on QTabBar

How would you change the text size and font in a QTabWidget?

class TabBar(QtGui.QTabBar):
    def ???(self, ???):

With a stylesheet. You don't need to subclass for that. But from your previous question , you are doing that already. You might as well put this in the __init__ too..

class TabBar(QtGui.QTabBar):
    def __init__(self, parent=None):
        super(TabBar, self).__init__(parent)

        self.setStyleSheet('font-size: 18pt; font-family: Courier;')

If you don't want to use a custom QTabBar the equivalent would be setting the stylesheet on relevant QTabWidget with a selector of QTabBar :

myTabWidget.setStyleSheet('QTabBar { font-size: 18pt; font-family: Courier; }')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM