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)
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.
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 .
Parameters: | w – PySide.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 .
Parameters: |
---|
Parameters: |
---|
Parameters: |
|
---|
Draws the pixmap in rectangle rect . The pixmap is aligned according to flags .
See also
QStyle.drawItemPixmap() Qt.Alignment
Parameters: |
|
---|
Parameters: |
---|
Return type: | PySide.QtGui.QStyle |
---|
Return the current style used by the PySide.QtGui.QStylePainter .