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)
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.
This is an overloaded function.
Begin painting operations on paint device pd as if it was widget .
|Parameters:||w – PySide.QtGui.QWidget|
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 .
Draws the pixmap in rectangle rect . The pixmap is aligned according to flags .