MCPcopy Index your code
hub / github.com/PyQt5/PyQt / subControlRect

Method subControlRect

QSlider/PaintQSlider.py:21–50  ·  view source on GitHub ↗
(self, control, option, subControl, widget=None)

Source from the content-addressed store, hash-verified

19class 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
53class PaintQSlider(QSlider):

Callers 3

paintEventMethod · 0.80
mousePressEventMethod · 0.80
drawControlMethod · 0.80

Calls 4

yMethod · 0.80
heightMethod · 0.45
xMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected