[QtGui module]

该QStylePainter类是一个方便的类用于绘图QStyle窗口小部件中的元素。More…

继承QPainter

Methods

  • __init__ (self)
  • __init__ (self, QWidget w)
  • __init__ (self, QPaintDevice pd, QWidget w)
  • bool begin (self, QWidget w)
  • bool begin (self, QPaintDevice pd, QWidget w)
  • drawComplexControl (self, QStyle.ComplexControl cc, QStyleOptionComplex opt)
  • drawControl (self, QStyle.ControlElement ce, QStyleOption opt)
  • drawItemPixmap (self, QRect r, int flags, QPixmap pixmap)
  • drawItemText (self, QRect rect, int flags, QPalette pal, bool enabled, QString text, QPalette.ColorRole textRole = QPalette.NoRole)
  • drawPrimitive (self, QStyle.PrimitiveElement pe, QStyleOption opt)
  • QStyle style (self)

Detailed Description

该QStylePainter类是一个方便的类用于绘图QStyle窗口小部件中的元素。

QStylePainter延伸QPainter用一组高级别draw...()之上实现的功能QStyle的API 。使用QStylePainter的优点在于,在参数列表获得相当短。而一个QStyle对象必须能够借鉴使用任何画家的任何小部件(因为应用程序通常有一个QStyle对象由所有部件共享) ,一个QStylePainter与一个插件初始化,而无需指定QWidget时,QPainterQStyle对于每个函数调用。

使用示例QStyle直接:

  1. void MyWidget.paintEvent([QPaintEvent](docs_qpaintevent.html) * /* event */)
  2. {
  3. [QPainter](docs_qpainter.html) painter(this);
  4. [QStyleOptionFocusRect](docs_qstyleoptionfocusrect.html) option;
  5. option.initFrom(this);
  6. option.backgroundColor = palette().color([QPalette](docs_qpalette.html).Background);
  7. style()->drawPrimitive([QStyle](docs_qstyle.html).PE_FrameFocusRect, &option, &painter, this);
  8. }

例如,使用QStylePainter :

  1. void MyWidget.paintEvent([QPaintEvent](docs_qpaintevent.html) * /* event */)
  2. {
  3. QStylePainter painter(this);
  4. [QStyleOptionFocusRect](docs_qstyleoptionfocusrect.html) option;
  5. option.initFrom(this);
  6. option.backgroundColor = palette().color([QPalette](docs_qpalette.html).Background);
  7. painter.drawPrimitive([QStyle](docs_qstyle.html).PE_FrameFocusRect, option);
  8. }

Method Documentation

  1. QStylePainter.__init__ (self)

构造一个QStylePainter

  1. QStylePainter.__init__ (self, QWidget w)

构建QStylePainter使用小工具widget它的漆设备。

  1. QStylePainter.__init__ (self, QPaintDevice pd, QWidget w)

构建QStylePainter using pd其油漆设备,然后从属性widget

  1. bool QStylePainter.begin (self, QWidget w)

开始绘制操作上的指定widget。返回True如果画家是准备使用,否则返回False 。

这是通过采用一个构造函数自动调用QWidget

  1. bool QStylePainter.begin (self, QPaintDevice pd, QWidget w)

这是一个重载函数。

开始绘制操作绘图设备上pd就好像它是widget

这是通过采用一个构造函数自动调用QPaintDeviceQWidget

  1. QStylePainter.drawComplexControl (self, QStyle.ComplexControl cc, QStyleOptionComplex opt)

使用widget的样式来绘制复杂的控制cc由指定的QStyleOptionComplex option

See also QStyle.drawComplexControl( ) 。

  1. QStylePainter.drawControl (self, QStyle.ControlElement ce, QStyleOption opt)

使用widget的样式来绘制控制元件ce通过指定QStyleOption option

See also QStyle.drawControl( ) 。

  1. QStylePainter.drawItemPixmap (self, QRect r, int flags, QPixmap pixmap)

绘制pixmap在矩形rect。像素图是根据对准的flags

See also QStyle.drawItemPixmap()和Qt.Alignment

  1. QStylePainter.drawItemText (self, QRect rect, int flags, QPalette pal, bool enabled, QString text, QPalette.ColorRole textRole = QPalette.NoRole)

绘制text在矩形rect和调色板pal。该文本是根据对齐和包裹flags

笔的颜色是指定textRole。该enabled布尔值指示是否该项目被启用,当重新实现这个布尔应该如何影响该项目的结论。

See also QStyle.drawItemText()和Qt.Alignment

  1. QStylePainter.drawPrimitive (self, QStyle.PrimitiveElement pe, QStyleOption opt)

使用widget的样式来绘制一个本原元pe通过指定QStyleOption option

See also QStyle.drawPrimitive( ) 。

  1. QStyle QStylePainter.style (self)

返回所使用的当前样式QStylePainter