2018-12-27 16:01:51 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
Created on 2018年12月27日
|
|
|
|
@author: Irony
|
2021-07-13 14:52:26 +08:00
|
|
|
@site: https://pyqt.site , https://github.com/PyQt5
|
2018-12-27 16:01:51 +08:00
|
|
|
@email: 892768447@qq.com
|
|
|
|
@file: TabBarStyle
|
|
|
|
@description:
|
|
|
|
"""
|
|
|
|
from PyQt5.QtCore import Qt
|
|
|
|
from PyQt5.QtWidgets import QProxyStyle
|
|
|
|
|
|
|
|
|
|
|
|
class TabBarStyle(QProxyStyle):
|
|
|
|
|
|
|
|
def sizeFromContents(self, types, option, size, widget):
|
|
|
|
size = super(TabBarStyle, self).sizeFromContents(
|
|
|
|
types, option, size, widget)
|
|
|
|
if types == self.CT_TabBarTab:
|
|
|
|
size.transpose()
|
|
|
|
return size
|
|
|
|
|
|
|
|
def drawControl(self, element, option, painter, widget):
|
|
|
|
if element == self.CE_TabBarTabLabel:
|
|
|
|
painter.drawText(option.rect, Qt.AlignCenter, option.text)
|
|
|
|
return
|
|
|
|
super(TabBarStyle, self).drawControl(element, option, painter, widget)
|