| 21 | class TabCornerStyle(QProxyStyle): |
| 22 | |
| 23 | def subElementRect(self, element, option, widget): |
| 24 | try: |
| 25 | rect = super(TabCornerStyle, self).subElementRect(element, option, widget) |
| 26 | if element == QStyle.SE_TabWidgetRightCorner and rect.isValid(): |
| 27 | # 标签tab的矩形范围 |
| 28 | tab_rect = self.subElementRect(QStyle.SE_TabWidgetTabBar, option, widget) |
| 29 | # 内容面板的矩形范围 |
| 30 | panel_rect = self.subElementRect(QStyle.SE_TabWidgetTabPane, option, widget) |
| 31 | ext_height = 2 * self.pixelMetric(QStyle.PM_TabBarBaseHeight, option, widget) |
| 32 | # 修正过后填充的矩形范围 |
| 33 | cor_rect = QRect(tab_rect.x() + tab_rect.width() + ext_height, tab_rect.y() + ext_height, |
| 34 | panel_rect.width() - tab_rect.width() - 2 * ext_height, |
| 35 | tab_rect.height() - 2 * ext_height) |
| 36 | return cor_rect |
| 37 | return rect |
| 38 | except Exception as e: |
| 39 | print(e) |
| 40 | return QRect() |