[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时,QPainter和QStyle对于每个函数调用。
使用示例QStyle直接:
void MyWidget.paintEvent([QPaintEvent](docs_qpaintevent.html) * /* event */)
{
[QPainter](docs_qpainter.html) painter(this);
[QStyleOptionFocusRect](docs_qstyleoptionfocusrect.html) option;
option.initFrom(this);
option.backgroundColor = palette().color([QPalette](docs_qpalette.html).Background);
style()->drawPrimitive([QStyle](docs_qstyle.html).PE_FrameFocusRect, &option, &painter, this);
}
例如,使用QStylePainter :
void MyWidget.paintEvent([QPaintEvent](docs_qpaintevent.html) * /* event */)
{
QStylePainter painter(this);
[QStyleOptionFocusRect](docs_qstyleoptionfocusrect.html) option;
option.initFrom(this);
option.backgroundColor = palette().color([QPalette](docs_qpalette.html).Background);
painter.drawPrimitive([QStyle](docs_qstyle.html).PE_FrameFocusRect, option);
}
Method Documentation
QStylePainter.__init__ (self)
构造一个QStylePainter。
QStylePainter.__init__ (self, QWidget w)
构建QStylePainter使用小工具widget它的漆设备。
QStylePainter.__init__ (self, QPaintDevice pd, QWidget w)
构建QStylePainter using pd其油漆设备,然后从属性widget。
bool QStylePainter.begin (self, QWidget w)
开始绘制操作上的指定widget。返回True如果画家是准备使用,否则返回False 。
这是通过采用一个构造函数自动调用QWidget。
bool QStylePainter.begin (self, QPaintDevice pd, QWidget w)
这是一个重载函数。
开始绘制操作绘图设备上pd就好像它是widget。
这是通过采用一个构造函数自动调用QPaintDevice和QWidget。
QStylePainter.drawComplexControl (self, QStyle.ComplexControl cc, QStyleOptionComplex opt)
使用widget的样式来绘制复杂的控制cc由指定的QStyleOptionComplex option。
See also QStyle.drawComplexControl( ) 。
QStylePainter.drawControl (self, QStyle.ControlElement ce, QStyleOption opt)
使用widget的样式来绘制控制元件ce通过指定QStyleOption option。
See also QStyle.drawControl( ) 。
QStylePainter.drawItemPixmap (self, QRect r, int flags, QPixmap pixmap)
绘制pixmap在矩形rect。像素图是根据对准的flags。
See also QStyle.drawItemPixmap()和Qt.Alignment。
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。
QStylePainter.drawPrimitive (self, QStyle.PrimitiveElement pe, QStyleOption opt)
使用widget的样式来绘制一个本原元pe通过指定QStyleOption option。
See also QStyle.drawPrimitive( ) 。
QStyle QStylePainter.style (self)