QStylePainterclass is a convenience class for drawingQStyle元素在 Widget 内。 更多 …
def
begin
(pd, w)
def
begin
(w)
def
drawComplexControl
(cc, opt)
def
drawControl
(ce, opt)
def
drawItemPixmap
(r, flags, pixmap)
def
drawItemText
(r, flags, pal, enabled, text[, textRole=QPalette.NoRole])
def
drawPrimitive
(pe, opt)
def
style
()
QStylePainterextendsQPainterwith a set of high-leveldraw...()functions implemented on top ofQStyle‘s API. The advantage of usingQStylePainteris that the parameter lists get considerably shorter. Whereas aQStyleobject must be able to draw on any widget using any painter (because the application normally has oneQStyleobject shared by all widget), aQStylePainteris initialized with a widget, eliminating the need to specify theQWidget,QPainter,和QStylefor every function call.Example using
QStyledirectly:def paintEvent(self, event): painter = QPainter(self) option = QStyleOptionFocusRect() option.initFrom(self) option.backgroundColor = palette().color(QPalette.Background) style().drawPrimitive(QStyle.PE_FrameFocusRect, option, painter, self)Example using
QStylePainter:def paintEvent(self, event): { painter = QStylePainter(self) option = QStyleOptionFocusRect() option.initFrom(self) option.backgroundColor = palette().color(QPalette.Background) painter.drawPrimitive(QStyle.PE_FrameFocusRect, option)另请参阅
QStylePainter
¶
QStylePainter(pd, w)
QStylePainter(w)
- param w
- param pd
QPaintDevice
构造
QStylePainter
.
构造
QStylePainter
使用
pd
for its paint device, and attributes from
widget
.
构造
QStylePainter
using widget
widget
for its paint device.
PySide2.QtWidgets.QStylePainter.
begin
(
pd
,
w
)
¶
pd
–
QPaintDevice
w
–
QWidget
bool
这是重载函数。
Begin painting operations on paint device
pd
as if it was
widget
.
This is automatically called by the constructor that takes a
QPaintDevice
和
QWidget
.
PySide2.QtWidgets.QStylePainter.
begin
(
w
)
¶
w
–
QWidget
bool
Begin painting operations on the specified
widget
。返回
true
if the painter is ready to use; otherwise returns
false
.
This is automatically called by the constructor that takes a
QWidget
.
PySide2.QtWidgets.QStylePainter.
drawComplexControl
(
cc
,
opt
)
¶
cc
–
ComplexControl
opt
–
QStyleOptionComplex
Use the widget’s style to draw a complex control
cc
specified by the
QStyleOptionComplex
option
.
另请参阅
PySide2.QtWidgets.QStylePainter.
drawControl
(
ce
,
opt
)
¶
ce
–
ControlElement
opt
–
QStyleOption
Use the widget’s style to draw a control element
ce
指定通过
QStyleOption
option
.
另请参阅
PySide2.QtWidgets.QStylePainter.
drawItemPixmap
(
r
,
flags
,
pixmap
)
¶
r
–
QRect
flags
–
int
pixmap
–
QPixmap
Draws the
pixmap
in rectangle
rect
. The pixmap is aligned according to
flags
.
另请参阅
drawItemPixmap()
Alignment
PySide2.QtWidgets.QStylePainter.
drawItemText
(
r
,
flags
,
pal
,
enabled
,
text
[
,
textRole=QPalette.NoRole
]
)
¶
r
–
QRect
flags
–
int
pal
–
QPalette
enabled
–
bool
text – unicode
textRole
–
ColorRole
Draws the
text
in rectangle
rect
and palette
pal
. The text is aligned and wrapped according to
flags
.
The pen color is specified with
textRole
。
enabled
bool indicates whether or not the item is enabled; when reimplementing this bool should influence how the item is drawn.
另请参阅
drawItemText()
Alignment
PySide2.QtWidgets.QStylePainter.
drawPrimitive
(
pe
,
opt
)
¶
pe
–
PrimitiveElement
opt
–
QStyleOption
Use the widget’s style to draw a primitive element
pe
指定通过
QStyleOption
option
.
另请参阅
PySide2.QtWidgets.QStylePainter.
style
(
)
¶
Return the current style used by the
QStylePainter
.