• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QPainter

    下一话题

    QPainter.PixmapFragment

    QStylePainter

    概要

    函数

    详细描述

    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)
    									
    class PySide.QtGui. QStylePainter
    class PySide.QtGui. QStylePainter ( pd , w )
    class PySide.QtGui. QStylePainter ( w )
    参数:

    构造 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.QtGui.QStylePainter. begin ( pd , w )
    参数:
    返回类型:

    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 .

    PySide.QtGui.QStylePainter. begin ( w )
    参数: 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 .

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

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

    另请参阅

    QStyle.drawItemPixmap() Qt.Alignment

    PySide.QtGui.QStylePainter. drawItemText ( r , flags , pal , enabled , text [ , textRole=QPalette.NoRole ] )
    参数:
    PySide.QtGui.QStylePainter. drawPrimitive ( pe , opt )
    参数:
    PySide.QtGui.QStylePainter. style ( )
    返回类型: PySide.QtGui.QStyle

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