Table Of Contents

Previous topic

QPainter

Next topic

QPainter.PixmapFragment

QStylePainter

Synopsis

Functions

Detailed Description

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

PySide.QtGui.QStylePainter extends PySide.QtGui.QPainter with a set of high-level draw...() functions implemented on top of PySide.QtGui.QStyle ‘s API. The advantage of using PySide.QtGui.QStylePainter is that the parameter lists get considerably shorter. Whereas a PySide.QtGui.QStyle object must be able to draw on any widget using any painter (because the application normally has one PySide.QtGui.QStyle object shared by all widget), a PySide.QtGui.QStylePainter is initialized with a widget, eliminating the need to specify the PySide.QtGui.QWidget , the PySide.QtGui.QPainter , and the PySide.QtGui.QStyle for every function call.

Example using PySide.QtGui.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 PySide.QtGui.QStylePainter :

def paintEvent(self, event):
<Code snippet "doc/src/snippets/styles/styles.cpp:4" not found>            painter = QStylePainter(self)


    option = QStyleOptionFocusRect()
    option.initFrom(self)
    option.backgroundColor = palette().color(QPalette.Background)


    painter.drawPrimitive(QStyle.PE_FrameFocusRect, option)
class PySide.QtGui.QStylePainter
class PySide.QtGui.QStylePainter(pd, w)
class PySide.QtGui.QStylePainter(w)
Parameters:

Constructs a PySide.QtGui.QStylePainter .

Construct a PySide.QtGui.QStylePainter using pd for its paint device, and attributes from widget .

Construct a PySide.QtGui.QStylePainter using widget widget for its paint device.

PySide.QtGui.QStylePainter.begin(pd, w)
Parameters:
Return type:

PySide.QtCore.bool

This is an overloaded function.

Begin painting operations on paint device pd as if it was widget .

This is automatically called by the constructor that takes a PySide.QtGui.QPaintDevice and a PySide.QtGui.QWidget .

PySide.QtGui.QStylePainter.begin(w)
Parameters:wPySide.QtGui.QWidget
Return type:PySide.QtCore.bool

Begin painting operations on the specified widget . Returns true if the painter is ready to use; otherwise returns false.

This is automatically called by the constructor that takes a PySide.QtGui.QWidget .

PySide.QtGui.QStylePainter.drawComplexControl(cc, opt)
Parameters:
PySide.QtGui.QStylePainter.drawControl(ce, opt)
Parameters:
PySide.QtGui.QStylePainter.drawItemPixmap(r, flags, pixmap)
Parameters:

Draws the pixmap in rectangle rect . The pixmap is aligned according to flags .

See also

QStyle.drawItemPixmap() Qt.Alignment

PySide.QtGui.QStylePainter.drawItemText(r, flags, pal, enabled, text[, textRole=QPalette.NoRole])
Parameters:
PySide.QtGui.QStylePainter.drawPrimitive(pe, opt)
Parameters:
PySide.QtGui.QStylePainter.style()
Return type:PySide.QtGui.QStyle

Return the current style used by the PySide.QtGui.QStylePainter .