QStylePainter

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

Inheritance diagram of PySide6.QtWidgets.QStylePainter

Synopsis

Functions

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, */):



    painter = QPainter(self)



    style().drawPrimitive(QStyle.PE_FrameFocusRect, option, painter, self)

Example using QStylePainter :

def paintEvent(self, */):        {        painter = QStylePainter(self)



painter.drawPrimitive(QStyle.PE_FrameFocusRect, option)

See also

QStyle QStyleOption

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

wPySide6.QtWidgets.QWidget

Return type

bool

PySide6.QtWidgets.QStylePainter.drawComplexControl(cc, opt)
Parameters
PySide6.QtWidgets.QStylePainter.drawControl(ce, opt)
Parameters
PySide6.QtWidgets.QStylePainter.drawItemPixmap(r, flags, pixmap)
Parameters
PySide6.QtWidgets.QStylePainter.drawItemText(r, flags, pal, enabled, text[, textRole=QPalette.NoRole])
Parameters
PySide6.QtWidgets.QStylePainter.drawPrimitive(pe, opt)
Parameters
PySide6.QtWidgets.QStylePainter.style()
Return type

PySide6.QtWidgets.QStyle