PySide.QtGui.QStylePainter class is a convenience class for drawing PySide.QtGui.QStyle 元素在 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 , PySide.QtGui.QPainter ,和 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)
| 参数: |
|---|
构造 PySide.QtGui.QStylePainter .
构造 PySide.QtGui.QStylePainter 使用 pd for its paint device, and attributes from widget .
构造 PySide.QtGui.QStylePainter using widget widget for its paint device.
| 参数: | |
|---|---|
| 返回类型: |
PySide.QtCore.bool |
这是重载函数。
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 和 PySide.QtGui.QWidget .
| 参数: | w – PySide.QtGui.QWidget |
|---|---|
| 返回类型: | 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 .
| 参数: |
|---|
| 参数: |
|---|
| 参数: |
|
|---|
Draws the pixmap in rectangle rect . The pixmap is aligned according to flags .
另请参阅
QStyle.drawItemPixmap() Qt.Alignment
| 参数: |
|
|---|
| 参数: |
|---|
| 返回类型: | PySide.QtGui.QStyle |
|---|
Return the current style used by the PySide.QtGui.QStylePainter .