(self, control, option, subControl, widget=None)
| 19 | class SliderStyle(QProxyStyle): |
| 20 | |
| 21 | def subControlRect(self, control, option, subControl, widget=None): |
| 22 | rect = super(SliderStyle, self).subControlRect( |
| 23 | control, option, subControl, widget) |
| 24 | if subControl == QStyle.SC_SliderHandle: |
| 25 | if option.orientation == Qt.Horizontal: |
| 26 | # 高度1/3 |
| 27 | radius = int(widget.height() / 3) |
| 28 | offset = int(radius / 3) |
| 29 | if option.state & QStyle.State_MouseOver: |
| 30 | x = min(rect.x() - offset, widget.width() - radius) |
| 31 | x = x if x >= 0 else 0 |
| 32 | else: |
| 33 | radius = offset |
| 34 | x = min(rect.x(), widget.width() - radius) |
| 35 | rect = QRect(x, int((rect.height() - radius) / 2), |
| 36 | radius, radius) |
| 37 | else: |
| 38 | # 宽度1/3 |
| 39 | radius = int(widget.width() / 3) |
| 40 | offset = int(radius / 3) |
| 41 | if option.state & QStyle.State_MouseOver: |
| 42 | y = min(rect.y() - offset, widget.height() - radius) |
| 43 | y = y if y >= 0 else 0 |
| 44 | else: |
| 45 | radius = offset |
| 46 | y = min(rect.y(), widget.height() - radius) |
| 47 | rect = QRect(int((rect.width() - radius) / 2), |
| 48 | y, radius, radius) |
| 49 | return rect |
| 50 | return rect |
| 51 | |
| 52 | |
| 53 | class PaintQSlider(QSlider): |
no test coverage detected