QStylePainter¶
The QStylePainter
class is a convenience class for drawing QStyle
elements inside a widget. More…

Synopsis¶
Functions¶
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
()
Detailed Description¶
QStylePainter
extends QPainter
with a set of high-level draw...()
functions implemented on top of QStyle
‘s 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:
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)See also
-
class
PySide6.QtWidgets.
QStylePainter
¶ PySide6.QtWidgets.QStylePainter(pd, w)
PySide6.QtWidgets.QStylePainter(w)
- Parameters
-
PySide6.QtWidgets.QStylePainter.
begin
(pd, w)¶ - Parameters
- Return type
bool
-
PySide6.QtWidgets.QStylePainter.
begin
(w) - Parameters
- Return type
bool
-
PySide6.QtWidgets.QStylePainter.
drawComplexControl
(cc, opt)¶ - Parameters
-
PySide6.QtWidgets.QStylePainter.
drawControl
(ce, opt)¶ - Parameters
ce –
ControlElement
-
PySide6.QtWidgets.QStylePainter.
drawItemPixmap
(r, flags, pixmap)¶ - Parameters
flags – int
pixmap –
PySide6.QtGui.QPixmap
-
PySide6.QtWidgets.QStylePainter.
drawItemText
(r, flags, pal, enabled, text[, textRole=QPalette.NoRole])¶ - Parameters
flags – int
pal –
PySide6.QtGui.QPalette
enabled – bool
text – str
textRole –
ColorRole
-
PySide6.QtWidgets.QStylePainter.
drawPrimitive
(pe, opt)¶ - Parameters
pe –
PrimitiveElement
-
PySide6.QtWidgets.QStylePainter.
style
()¶ - Return type
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.