1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QStylePainter Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QStylePainter Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QStylePainter class is a convenience class for drawing <a href="qstyle.html">QStyle</a> elements inside a widget. <a href="#details">More...</a></p>
<p>Inherits <a href="qpainter.html">QPainter</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qstylepainter.html#QStylePainter">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstylepainter.html#QStylePainter-2">__init__</a></b> (<i>self</i>, QWidget)</li><li><div class="fn" /><b><a href="qstylepainter.html#QStylePainter-3">__init__</a></b> (<i>self</i>, QPaintDevice, QWidget)</li><li><div class="fn" />bool <b><a href="qstylepainter.html#begin">begin</a></b> (<i>self</i>, QWidget)</li><li><div class="fn" />bool <b><a href="qstylepainter.html#begin-2">begin</a></b> (<i>self</i>, QPaintDevice, QWidget)</li><li><div class="fn" /><b><a href="qstylepainter.html#drawComplexControl">drawComplexControl</a></b> (<i>self</i>, QStyle.ComplexControl, QStyleOptionComplex)</li><li><div class="fn" /><b><a href="qstylepainter.html#drawControl">drawControl</a></b> (<i>self</i>, QStyle.ControlElement, QStyleOption)</li><li><div class="fn" /><b><a href="qstylepainter.html#drawItemPixmap">drawItemPixmap</a></b> (<i>self</i>, QRect, int, QPixmap)</li><li><div class="fn" /><b><a href="qstylepainter.html#drawItemText">drawItemText</a></b> (<i>self</i>, QRect, int, QPalette, bool, QString, QPalette.ColorRole <i>textRole</i> = QPalette.NoRole)</li><li><div class="fn" /><b><a href="qstylepainter.html#drawPrimitive">drawPrimitive</a></b> (<i>self</i>, QStyle.PrimitiveElement, QStyleOption)</li><li><div class="fn" />QStyle <b><a href="qstylepainter.html#style">style</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QStylePainter class is a convenience class for drawing <a href="qstyle.html">QStyle</a> elements inside a widget.</p>
<p>QStylePainter extends <a href="qpainter.html">QPainter</a> with a set of high-level <tt>draw...()</tt> functions implemented on top of <a href="qstyle.html">QStyle</a>'s API. The advantage of using QStylePainter is that the parameter lists get considerably shorter. Whereas a <a href="qstyle.html">QStyle</a> object must be able to draw on any widget using any painter (because the application normally has one <a href="qstyle.html">QStyle</a> object shared by all widget), a QStylePainter is initialized with a widget, eliminating the need to specify the <a href="qwidget.html">QWidget</a>, the <a href="qpainter.html">QPainter</a>, and the <a href="qstyle.html">QStyle</a> for every function call.</p>
<p>Example using <a href="qstyle.html">QStyle</a> directly:</p>
<pre> void MyWidget.paintEvent(QPaintEvent * <span class="comment">/* event */</span>)
{
QPainter painter(this);
QStyleOptionFocusRect option;
option.initFrom(this);
option.backgroundColor = palette().color(QPalette.Background);
style()->drawPrimitive(QStyle.PE_FrameFocusRect, &option, &painter, this);
}</pre>
<p>Example using QStylePainter:</p>
<pre> void MyWidget.paintEvent(QPaintEvent * <span class="comment">/* event */</span>)
{
QStylePainter painter(this);
QStyleOptionFocusRect option;
option.initFrom(this);
option.backgroundColor = palette().color(QPalette.Background);
painter.drawPrimitive(QStyle.PE_FrameFocusRect, option);
}</pre>
<p>See also <a href="qstyle.html">QStyle</a> and <a href="qstyleoption.html">QStyleOption</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QStylePainter" />QStylePainter.__init__ (<i>self</i>)</h3><p>Constructs a <a href="qstylepainter.html">QStylePainter</a>.</p>
<h3 class="fn"><a name="QStylePainter-2" />QStylePainter.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a>)</h3><p>Construct a <a href="qstylepainter.html">QStylePainter</a> using widget <i>widget</i> for its paint device.</p>
<h3 class="fn"><a name="QStylePainter-3" />QStylePainter.__init__ (<i>self</i>, <a href="qpaintdevice.html">QPaintDevice</a>, <a href="qwidget.html">QWidget</a>)</h3><p>Construct a <a href="qstylepainter.html">QStylePainter</a> using <i>pd</i> for its paint device, and attributes from <i>widget</i>.</p>
<a name="//apple_ref/cpp/instm/QStylePainter/begin" />
<h3 class="fn"><a name="begin" />bool QStylePainter.begin (<i>self</i>, <a href="qwidget.html">QWidget</a>)</h3><p>Begin painting operations on the specified <i>widget</i>. Returns true if the painter is ready to use; otherwise returns false.</p>
<p>This is automatically called by the constructor that takes a <a href="qwidget.html">QWidget</a>.</p>
<h3 class="fn"><a name="begin-2" />bool QStylePainter.begin (<i>self</i>, <a href="qpaintdevice.html">QPaintDevice</a>, <a href="qwidget.html">QWidget</a>)</h3><p>This is an overloaded function.</p>
<p>Begin painting operations on paint device <i>pd</i> as if it was <i>widget</i>.</p>
<p>This is automatically called by the constructor that takes a <a href="qpaintdevice.html">QPaintDevice</a> and a <a href="qwidget.html">QWidget</a>.</p>
<a name="//apple_ref/cpp/instm/QStylePainter/drawComplexControl" />
<h3 class="fn"><a name="drawComplexControl" />QStylePainter.drawComplexControl (<i>self</i>, <a href="qstyle.html#ComplexControl-enum">QStyle.ComplexControl</a>, <a href="qstyleoptioncomplex.html">QStyleOptionComplex</a>)</h3><p>Use the widget's style to draw a complex control <i>cc</i> specified by the <a href="qstyleoptioncomplex.html">QStyleOptionComplex</a> <i>option</i>.</p>
<p>See also <a href="qstyle.html#drawComplexControl">QStyle.drawComplexControl</a>().</p>
<a name="//apple_ref/cpp/instm/QStylePainter/drawControl" />
<h3 class="fn"><a name="drawControl" />QStylePainter.drawControl (<i>self</i>, <a href="qstyle.html#ControlElement-enum">QStyle.ControlElement</a>, <a href="qstyleoption.html">QStyleOption</a>)</h3><p>Use the widget's style to draw a control element <i>ce</i> specified by <a href="qstyleoption.html">QStyleOption</a> <i>option</i>.</p>
<p>See also <a href="qstyle.html#drawControl">QStyle.drawControl</a>().</p>
<a name="//apple_ref/cpp/instm/QStylePainter/drawItemPixmap" />
<h3 class="fn"><a name="drawItemPixmap" />QStylePainter.drawItemPixmap (<i>self</i>, <a href="qrect.html">QRect</a>, int, <a href="qpixmap.html">QPixmap</a>)</h3><p>Draws the <i>pixmap</i> in rectangle <i>rect</i>. The pixmap is aligned according to <i>flags</i>.</p>
<p>See also <a href="qstyle.html#drawItemPixmap">QStyle.drawItemPixmap</a>() and <a href="qt.html#AlignmentFlag-enum">Qt.Alignment</a>.</p>
<a name="//apple_ref/cpp/instm/QStylePainter/drawItemText" />
<h3 class="fn"><a name="drawItemText" />QStylePainter.drawItemText (<i>self</i>, <a href="qrect.html">QRect</a>, int, <a href="qpalette.html">QPalette</a>, bool, QString, <a href="qpalette.html#ColorRole-enum">QPalette.ColorRole</a> <i>textRole</i> = QPalette.NoRole)</h3><p>Draws the <i>text</i> in rectangle <i>rect</i> and palette <i>pal</i>. The text is aligned and wrapped according to <i>flags</i>.</p>
<p>The pen color is specified with <i>textRole</i>. The <i>enabled</i> bool indicates whether or not the item is enabled; when reimplementing this bool should influence how the item is drawn.</p>
<p>See also <a href="qstyle.html#drawItemText">QStyle.drawItemText</a>() and <a href="qt.html#AlignmentFlag-enum">Qt.Alignment</a>.</p>
<a name="//apple_ref/cpp/instm/QStylePainter/drawPrimitive" />
<h3 class="fn"><a name="drawPrimitive" />QStylePainter.drawPrimitive (<i>self</i>, <a href="qstyle.html#PrimitiveElement-enum">QStyle.PrimitiveElement</a>, <a href="qstyleoption.html">QStyleOption</a>)</h3><p>Use the widget's style to draw a primitive element <i>pe</i> specified by <a href="qstyleoption.html">QStyleOption</a> <i>option</i>.</p>
<p>See also <a href="qstyle.html#drawPrimitive">QStyle.drawPrimitive</a>().</p>
<a name="//apple_ref/cpp/instm/QStylePainter/style" />
<h3 class="fn"><a name="style" /><a href="qstyle.html">QStyle</a> QStylePainter.style (<i>self</i>)</h3><p>Return the current style used by the <a href="qstylepainter.html">QStylePainter</a>.</p>
<p /><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.7.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt 4.6.2</td></tr></table></div></address></body></html>
|