QStylePainter露
- PyQt5.QtWidgets.QStylePainter
Inherits from QPainter.
Description露
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
QStylePainter extends QPainter with a set of high-level draw...()
functions implemented on top of QStyle鈥檚 API. The advantage of using QStylePainter is that the parameter lists get considerably shorter. Whereas a QStyle object must be able to draw on any widget using any painter (because the application normally has one QStyle object shared by all widget), a QStylePainter is initialized with a widget, eliminating the need to specify the QWidget, the QPainter, and the QStyle for every function call.
Example using QStyle directly:
# void MyWidget::paintEvent(QPaintEvent * /* event */)
# #! [0]
# {
# #! [2]
# QPainter painter(this);
# #! [2]
# QStyleOptionFocusRect option;
# option.initFrom(this);
# option.backgroundColor = palette().color(QPalette::Background);
# #! [3]
# style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
# #! [3]
# }
Example using QStylePainter:
# void MyWidget::paintEvent(QPaintEvent * /* event */)
# {
# QStylePainter painter(this);
# #! [5]
# QStyleOptionFocusRect option;
# option.initFrom(this);
# option.backgroundColor = palette().color(QPalette::Background);
# #! [7]
# painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
# #! [7]
# }
See also
QStyleQStyleOption.
Methods露
- __init__()
TODO
- __init__(QWidget)
TODO
- __init__(QPaintDevice, QWidget)
TODO
- begin(QWidget) → bool
TODO
- begin(QPaintDevice, QWidget) → bool
TODO
- drawComplexControl(ComplexControl, QStyleOptionComplex)
TODO
- drawControl(ControlElement, QStyleOption)
TODO
- drawPrimitive(PrimitiveElement, QStyleOption)
TODO
- style() → QStyle
TODO