PyQt/QProxyStyle/Lib/TabBarStyle.py

37 lines
982 B
Python
Raw Normal View History

2018-12-27 16:01:51 +08:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2018年12月27日
@author: Irony
2018-12-28 23:09:46 +08:00
@site: https://pyqt5.com , https://github.com/892768447
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
__Author__ = """By: Irony
QQ: 892768447
Email: 892768447@qq.com"""
__Copyright__ = "Copyright (c) 2018 Irony"
__Version__ = "Version 1.0"
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)