File: qpen.html

package info (click to toggle)
python-qt4 4.11.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 39,748 kB
  • ctags: 6,146
  • sloc: python: 125,938; cpp: 12,612; xml: 292; makefile: 258; php: 27; sh: 27
file content (408 lines) | stat: -rw-r--r-- 31,258 bytes parent folder | download
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
<?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>QPen 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">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QPen Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QPen class defines how a <a href="qpainter.html">QPainter</a> should draw lines and outlines of
shapes. <a href="#details">More...</a></p>

<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qpen.html#QPen">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpen.html#QPen-2">__init__</a></b> (<i>self</i>, Qt.PenStyle)</li><li><div class="fn" /><b><a href="qpen.html#QPen-3">__init__</a></b> (<i>self</i>, QColor&#160;<i>color</i>)</li><li><div class="fn" /><b><a href="qpen.html#QPen-4">__init__</a></b> (<i>self</i>, QBrush&#160;<i>brush</i>, float&#160;<i>width</i>, Qt.PenStyle&#160;<i>style</i>&#160;=&#160;Qt.SolidLine, Qt.PenCapStyle&#160;<i>cap</i>&#160;=&#160;Qt.SquareCap, Qt.PenJoinStyle&#160;<i>join</i>&#160;=&#160;Qt.BevelJoin)</li><li><div class="fn" /><b><a href="qpen.html#QPen-5">__init__</a></b> (<i>self</i>, QPen&#160;<i>pen</i>)</li><li><div class="fn" /><b><a href="qpen.html#QPen-6">__init__</a></b> (<i>self</i>, QVariant&#160;<i>variant</i>)</li><li><div class="fn" />QBrush <b><a href="qpen.html#brush">brush</a></b> (<i>self</i>)</li><li><div class="fn" />Qt.PenCapStyle <b><a href="qpen.html#capStyle">capStyle</a></b> (<i>self</i>)</li><li><div class="fn" />QColor <b><a href="qpen.html#color">color</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qpen.html#dashOffset">dashOffset</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-float <b><a href="qpen.html#dashPattern">dashPattern</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qpen.html#isCosmetic">isCosmetic</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qpen.html#isSolid">isSolid</a></b> (<i>self</i>)</li><li><div class="fn" />Qt.PenJoinStyle <b><a href="qpen.html#joinStyle">joinStyle</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qpen.html#miterLimit">miterLimit</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpen.html#setBrush">setBrush</a></b> (<i>self</i>, QBrush&#160;<i>brush</i>)</li><li><div class="fn" /><b><a href="qpen.html#setCapStyle">setCapStyle</a></b> (<i>self</i>, Qt.PenCapStyle&#160;<i>pcs</i>)</li><li><div class="fn" /><b><a href="qpen.html#setColor">setColor</a></b> (<i>self</i>, QColor&#160;<i>color</i>)</li><li><div class="fn" /><b><a href="qpen.html#setCosmetic">setCosmetic</a></b> (<i>self</i>, bool&#160;<i>cosmetic</i>)</li><li><div class="fn" /><b><a href="qpen.html#setDashOffset">setDashOffset</a></b> (<i>self</i>, float&#160;<i>doffset</i>)</li><li><div class="fn" /><b><a href="qpen.html#setDashPattern">setDashPattern</a></b> (<i>self</i>, list-of-float&#160;<i>pattern</i>)</li><li><div class="fn" /><b><a href="qpen.html#setJoinStyle">setJoinStyle</a></b> (<i>self</i>, Qt.PenJoinStyle&#160;<i>pcs</i>)</li><li><div class="fn" /><b><a href="qpen.html#setMiterLimit">setMiterLimit</a></b> (<i>self</i>, float&#160;<i>limit</i>)</li><li><div class="fn" /><b><a href="qpen.html#setStyle">setStyle</a></b> (<i>self</i>, Qt.PenStyle)</li><li><div class="fn" /><b><a href="qpen.html#setWidth">setWidth</a></b> (<i>self</i>, int&#160;<i>width</i>)</li><li><div class="fn" /><b><a href="qpen.html#setWidthF">setWidthF</a></b> (<i>self</i>, float&#160;<i>width</i>)</li><li><div class="fn" />Qt.PenStyle <b><a href="qpen.html#style">style</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpen.html#swap">swap</a></b> (<i>self</i>, QPen&#160;<i>other</i>)</li><li><div class="fn" />int <b><a href="qpen.html#width">width</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qpen.html#widthF">widthF</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qpen.html#__eq__">__eq__</a></b> (<i>self</i>, QPen&#160;<i>p</i>)</li><li><div class="fn" />bool <b><a href="qpen.html#__ne__">__ne__</a></b> (<i>self</i>, QPen&#160;<i>p</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>A
    <a href="qcolor.html">QColor</a>
    may be used whenever a
    <a href="qpen.html">QPen</a>
    is expected.</p>
  <p>The QPen class defines how a <a href="qpainter.html">QPainter</a> should draw lines and outlines of
shapes.</p>
<p>A pen has a <a href="qpen.html#style">style</a>(), <a href="qpen.html#width">width</a>(), <a href="qpen.html#brush">brush</a>(), <a href="qpen.html#capStyle">capStyle</a>() and <a href="qpen.html#joinStyle">joinStyle</a>().</p>
<p>The pen style defines the line type. The brush is used to fill
strokes generated with the pen. Use the <a href="qbrush.html">QBrush</a> class to specify fill styles. The cap
style determines the line end caps that can be drawn using <a href="qpainter.html">QPainter</a>, while the join style describes how
joins between two lines are drawn. The pen width can be specified
in both integer (<a href="qpen.html#width">width</a>()) and
floating point (<a href="qpen.html#widthF">widthF</a>()) precision.
A line width of zero indicates a cosmetic pen. This means that the
pen width is always drawn one pixel wide, independent of the
<a href="qpainter.html#coordinate-transformations">transformation</a> set
on the painter.</p>
<p>The various settings can easily be modified using the
corresponding <a href="qpen.html#setStyle">setStyle</a>(), <a href="qpen.html#setWidth">setWidth</a>(), <a href="qpen.html#setBrush">setBrush</a>(), <a href="qpen.html#setCapStyle">setCapStyle</a>() and <a href="qpen.html#setJoinStyle">setJoinStyle</a>() functions (note that
the painter's pen must be reset when altering the pen's
properties).</p>
<p>For example:</p>
<pre class="cpp">
 <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>);
 <span class="type">QPen</span> pen(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>green<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>DashDotLine<span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>RoundCap<span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>RoundJoin);
 painter<span class="operator">.</span>setPen(pen);
</pre>
<p>which is equivalent to</p>
<pre class="cpp">
 <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>);
 <span class="type">QPen</span> pen;  <span class="comment">// creates a default pen</span>

 pen<span class="operator">.</span><a href="qpen.html#setStyle">setStyle</a>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>DashDotLine);
 pen<span class="operator">.</span><a href="qpen.html#setWidth">setWidth</a>(<span class="number">3</span>);
 pen<span class="operator">.</span><a href="qpen.html#setBrush">setBrush</a>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>green);
 pen<span class="operator">.</span><a href="qpen.html#setCapStyle">setCapStyle</a>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>RoundCap);
 pen<span class="operator">.</span><a href="qpen.html#setJoinStyle">setJoinStyle</a>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>RoundJoin);

 painter<span class="operator">.</span>setPen(pen);
</pre>
<p>The default pen is a solid black brush with 0 width, square cap
style (<a href="qt.html#PenCapStyle-enum">Qt.SquareCap</a>), and
bevel join style (<a href="qt.html#PenJoinStyle-enum">Qt.BevelJoin</a>).</p>
<p>In addition QPen provides the <a href="qpen.html#color">color</a>() and <a href="qpen.html#setColor">setColor</a>() convenience functions to
extract and set the color of the pen's brush, respectively. Pens
may also be compared and streamed.</p>
<p>For more information about painting in general, see the <a href="paintsystem.html">Paint System</a> documentation.</p>
<a id="pen-style" name="pen-style" />
<h3>Pen Style</h3>
<p>Qt provides several built-in styles represented by the <a href="qt.html#PenStyle-enum">Qt.PenStyle</a> enum:</p>
<table class="generic">
<tr class="odd" valign="top">
<td><img alt="" src="images/qpen-solid.png" /></td>
<td><img alt="" src="images/qpen-dash.png" /></td>
<td><img alt="" src="images/qpen-dot.png" /></td>
</tr>
<tr class="even" valign="top">
<td><a href="qt.html#PenStyle-enum">Qt.SolidLine</a></td>
<td><a href="qt.html#PenStyle-enum">Qt.DashLine</a></td>
<td><a href="qt.html#PenStyle-enum">Qt.DotLine</a></td>
</tr>
<tr class="odd" valign="top">
<td><img alt="" src="images/qpen-dashdot.png" /></td>
<td><img alt="" src="images/qpen-dashdotdot.png" /></td>
<td><img alt="" src="images/qpen-custom.png" /></td>
</tr>
<tr class="even" valign="top">
<td><a href="qt.html#PenStyle-enum">Qt.DashDotLine</a></td>
<td><a href="qt.html#PenStyle-enum">Qt.DashDotDotLine</a></td>
<td><a href="qt.html#PenStyle-enum">Qt.CustomDashLine</a></td>
</tr>
</table>
<p>Simply use the <a href="qpen.html#setStyle">setStyle</a>()
function to convert the pen style to either of the built-in styles,
except the <a href="qt.html#PenStyle-enum">Qt.CustomDashLine</a>
style which we will come back to shortly. Setting the style to
<a href="qt.html#PenStyle-enum">Qt.NoPen</a> tells the painter to
not draw lines or outlines. The default pen style is <a href="qt.html#PenStyle-enum">Qt.SolidLine</a>.</p>
<p>Since Qt 4.1 it is also possible to specify a custom dash
pattern using the <a href="qpen.html#setDashPattern">setDashPattern</a>() function which
implicitly converts the style of the pen to <a href="qt.html#PenStyle-enum">Qt.CustomDashLine</a>. The pattern
argument, a <a href="qvector.html">QVector</a>, must be specified
as an even number of <a href="qtcore.html#qreal-typedef">qreal</a> entries where the entries
1, 3, 5... are the dashes and 2, 4, 6... are the spaces. For
example, the custom pattern shown above is created using the
following code:</p>
<pre class="cpp">
 <span class="type">QPen</span> pen;
 <span class="type"><a href="qvector.html">QVector</a></span><span class="operator">&lt;</span><span class="type"><a href="qtcore.html#qreal-typedef">qreal</a></span><span class="operator">&gt;</span> dashes;
 <span class="type"><a href="qtcore.html#qreal-typedef">qreal</a></span> space <span class="operator">=</span> <span class="number">4</span>;

 dashes <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="number">1</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> space <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="number">3</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> space <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="number">9</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> space
            <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="number">27</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> space <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="number">9</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> space;

 pen<span class="operator">.</span><a href="qpen.html#setDashPattern">setDashPattern</a>(dashes);
</pre>
<p>Note that the dash pattern is specified in units of the pens
width, e.g. a dash of length 5 in width 10 is 50 pixels long.</p>
<p>The currently set dash pattern can be retrieved using the
<a href="qpen.html#dashPattern">dashPattern</a>() function. Use the
<a href="qpen.html#isSolid">isSolid</a>() function to determine
whether the pen has a solid fill, or not.</p>
<a id="cap-style" name="cap-style" />
<h3>Cap Style</h3>
<p>The cap style defines how the end points of lines are drawn
using <a href="qpainter.html">QPainter</a>. The cap style only
apply to wide lines, i.e. when the width is 1 or greater. The
<a href="qt.html#PenCapStyle-enum">Qt.PenCapStyle</a> enum
provides the following styles:</p>
<table class="generic">
<tr class="odd" valign="top">
<td><img alt="" src="images/qpen-square.png" /></td>
<td><img alt="" src="images/qpen-flat.png" /></td>
<td><img alt="" src="images/qpen-roundcap.png" /></td>
</tr>
<tr class="even" valign="top">
<td><a href="qt.html#PenCapStyle-enum">Qt.SquareCap</a></td>
<td><a href="qt.html#PenCapStyle-enum">Qt.FlatCap</a></td>
<td><a href="qt.html#PenCapStyle-enum">Qt.RoundCap</a></td>
</tr>
</table>
<p>The <a href="qt.html#PenCapStyle-enum">Qt.SquareCap</a> style
is a square line end that covers the end point and extends beyond
it by half the line width. The <a href="qt.html#PenCapStyle-enum">Qt.FlatCap</a> style is a square line
end that does not cover the end point of the line. And the <a href="qt.html#PenCapStyle-enum">Qt.RoundCap</a> style is a rounded line
end covering the end point.</p>
<p>The default is <a href="qt.html#PenCapStyle-enum">Qt.SquareCap</a>.</p>
<p>Whether or not end points are drawn when the pen width is 0 or 1
depends on the cap style. Using <a href="qt.html#PenCapStyle-enum">Qt.SquareCap</a> or <a href="qt.html#PenCapStyle-enum">Qt.RoundCap</a> they are drawn, using
<a href="qt.html#PenCapStyle-enum">Qt.FlatCap</a> they are not
drawn.</p>
<a id="join-style" name="join-style" />
<h3>Join Style</h3>
<p>The join style defines how joins between two connected lines can
be drawn using <a href="qpainter.html">QPainter</a>. The join style
only apply to wide lines, i.e. when the width is 1 or greater. The
<a href="qt.html#PenJoinStyle-enum">Qt.PenJoinStyle</a> enum
provides the following styles:</p>
<table class="generic">
<tr class="odd" valign="top">
<td><img alt="" src="images/qpen-bevel.png" /></td>
<td><img alt="" src="images/qpen-miter.png" /></td>
<td><img alt="" src="images/qpen-roundjoin.png" /></td>
</tr>
<tr class="even" valign="top">
<td><a href="qt.html#PenJoinStyle-enum">Qt.BevelJoin</a></td>
<td><a href="qt.html#PenJoinStyle-enum">Qt.MiterJoin</a></td>
<td><a href="qt.html#PenJoinStyle-enum">Qt.RoundJoin</a></td>
</tr>
</table>
<p>The <a href="qt.html#PenJoinStyle-enum">Qt.BevelJoin</a> style
fills the triangular notch between the two lines. The <a href="qt.html#PenJoinStyle-enum">Qt.MiterJoin</a> style extends the
lines to meet at an angle. And the <a href="qt.html#PenJoinStyle-enum">Qt.RoundJoin</a> style fills a
circular arc between the two lines.</p>
<p>The default is <a href="qt.html#PenJoinStyle-enum">Qt.BevelJoin</a>.</p>
<p class="centerAlign"><img alt="" src="images/qpen-miterlimit.png" /></p>
<p>When the <a href="qt.html#PenJoinStyle-enum">Qt.MiterJoin</a>
style is applied, it is possible to use the <a href="qpen.html#setMiterLimit">setMiterLimit</a>() function to specify
how far the miter join can extend from the join point. The <a href="qpen.html#miterLimit">miterLimit</a>() is used to reduce artifacts
between line joins where the lines are close to parallel.</p>
<p>The <a href="qpen.html#miterLimit">miterLimit</a>() must be
specified in units of the pens width, e.g. a miter limit of 5 in
width 10 is 50 pixels long. The default miter limit is 2, i.e.
twice the pen width in pixels.</p>
<table class="generic" width="100%">
<tr class="odd" valign="top">
<td><img alt="" src="images/qpen-demo.png" /></td>
<td><b><a href="demos-pathstroke.html">The Path Stroking
Demo</a></b>
<p>The Path Stroking demo shows Qt's built-in dash patterns and
shows how custom patterns can be used to extend the range of
available patterns.</p>
</td>
</tr>
</table>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QPen" />QPen.__init__ (<i>self</i>)</h3><p>Constructs a default black solid line pen with 0 width.</p>


<h3 class="fn"><a name="QPen-2" />QPen.__init__ (<i>self</i>, <a href="qt.html#PenStyle-enum">Qt.PenStyle</a>)</h3><p>Constructs a black pen with 0 width and the given
<i>style</i>.</p>
<p><b>See also</b> <a href="qpen.html#setStyle">setStyle</a>().</p>


<h3 class="fn"><a name="QPen-3" />QPen.__init__ (<i>self</i>, <a href="qcolor.html">QColor</a>&#160;<i>color</i>)</h3><p>Constructs a solid line pen with 0 width and the given
<i>color</i>.</p>
<p><b>See also</b> <a href="qpen.html#setBrush">setBrush</a>() and
<a href="qpen.html#setColor">setColor</a>().</p>


<h3 class="fn"><a name="QPen-4" />QPen.__init__ (<i>self</i>, <a href="qbrush.html">QBrush</a>&#160;<i>brush</i>, float&#160;<i>width</i>, <a href="qt.html#PenStyle-enum">Qt.PenStyle</a>&#160;<i>style</i>&#160;=&#160;Qt.SolidLine, <a href="qt.html#PenCapStyle-enum">Qt.PenCapStyle</a>&#160;<i>cap</i>&#160;=&#160;Qt.SquareCap, <a href="qt.html#PenJoinStyle-enum">Qt.PenJoinStyle</a>&#160;<i>join</i>&#160;=&#160;Qt.BevelJoin)</h3><p>Constructs a pen with the specified <i>brush</i>, <i>width</i>,
pen <i>style</i>, <i>cap</i> style and <i>join</i> style.</p>
<p><b>See also</b> <a href="qpen.html#setBrush">setBrush</a>(),
<a href="qpen.html#setWidth">setWidth</a>(), <a href="qpen.html#setStyle">setStyle</a>(), <a href="qpen.html#setCapStyle">setCapStyle</a>(), and <a href="qpen.html#setJoinStyle">setJoinStyle</a>().</p>


<h3 class="fn"><a name="QPen-5" />QPen.__init__ (<i>self</i>, <a href="qpen.html">QPen</a>&#160;<i>pen</i>)</h3><p>Constructs a pen that is a copy of the given <i>pen</i>.</p>


<h3 class="fn"><a name="QPen-6" />QPen.__init__ (<i>self</i>, QVariant&#160;<i>variant</i>)</h3><h3 class="fn"><a name="brush" /><a href="qbrush.html">QBrush</a> QPen.brush (<i>self</i>)</h3><p>Returns the brush used to fill strokes generated with this
pen.</p>
<p><b>See also</b> <a href="qpen.html#setBrush">setBrush</a>().</p>


<h3 class="fn"><a name="capStyle" /><a href="qt.html#PenCapStyle-enum">Qt.PenCapStyle</a> QPen.capStyle (<i>self</i>)</h3><p>Returns the pen's cap style.</p>
<p><b>See also</b> <a href="qpen.html#setCapStyle">setCapStyle</a>() and <a href="qpen.html#cap-style">Cap Style</a>.</p>


<h3 class="fn"><a name="color" /><a href="qcolor.html">QColor</a> QPen.color (<i>self</i>)</h3><p>Returns the color of this pen's brush.</p>
<p><b>See also</b> <a href="qpen.html#brush">brush</a>() and
<a href="qpen.html#setColor">setColor</a>().</p>


<h3 class="fn"><a name="dashOffset" />float QPen.dashOffset (<i>self</i>)</h3><p>Returns the dash offset for the pen.</p>
<p><b>See also</b> <a href="qpen.html#setDashOffset">setDashOffset</a>().</p>


<h3 class="fn"><a name="dashPattern" />list-of-float QPen.dashPattern (<i>self</i>)</h3><p>Returns the dash pattern of this pen.</p>
<p><b>See also</b> <a href="qpen.html#setDashPattern">setDashPattern</a>(), <a href="qpen.html#style">style</a>(), and <a href="qpen.html#isSolid">isSolid</a>().</p>


<h3 class="fn"><a name="isCosmetic" />bool QPen.isCosmetic (<i>self</i>)</h3><p>Returns true if the pen is cosmetic; otherwise returns
false.</p>
<p>Cosmetic pens are used to draw strokes that have a constant
width regardless of any transformations applied to the <a href="qpainter.html">QPainter</a> they are used with. Drawing a shape
with a cosmetic pen ensures that its outline will have the same
thickness at different scale factors.</p>
<p>A zero width pen is cosmetic by default; pens with a non-zero
width are non-cosmetic.</p>
<p><b>See also</b> <a href="qpen.html#setCosmetic">setCosmetic</a>() and <a href="qpen.html#widthF">widthF</a>().</p>


<h3 class="fn"><a name="isSolid" />bool QPen.isSolid (<i>self</i>)</h3><p>Returns true if the pen has a solid fill, otherwise false.</p>
<p><b>See also</b> <a href="qpen.html#style">style</a>() and
<a href="qpen.html#dashPattern">dashPattern</a>().</p>


<h3 class="fn"><a name="joinStyle" /><a href="qt.html#PenJoinStyle-enum">Qt.PenJoinStyle</a> QPen.joinStyle (<i>self</i>)</h3><p>Returns the pen's join style.</p>
<p><b>See also</b> <a href="qpen.html#setJoinStyle">setJoinStyle</a>() and <a href="qpen.html#join-style">Join Style</a>.</p>


<h3 class="fn"><a name="miterLimit" />float QPen.miterLimit (<i>self</i>)</h3><p>Returns the miter limit of the pen. The miter limit is only
relevant when the join style is set to <a href="qt.html#PenJoinStyle-enum">Qt.MiterJoin</a>.</p>
<p><b>See also</b> <a href="qpen.html#setMiterLimit">setMiterLimit</a>() and <a href="qpen.html#join-style">Join Style</a>.</p>


<h3 class="fn"><a name="setBrush" />QPen.setBrush (<i>self</i>, <a href="qbrush.html">QBrush</a>&#160;<i>brush</i>)</h3><p>Sets the brush used to fill strokes generated with this pen to
the given <i>brush</i>.</p>
<p><b>See also</b> <a href="qpen.html#brush">brush</a>() and
<a href="qpen.html#setColor">setColor</a>().</p>


<h3 class="fn"><a name="setCapStyle" />QPen.setCapStyle (<i>self</i>, <a href="qt.html#PenCapStyle-enum">Qt.PenCapStyle</a>&#160;<i>pcs</i>)</h3><p>Sets the pen's cap style to the given <i>style</i>. The default
value is <a href="qt.html#PenCapStyle-enum">Qt.SquareCap</a>.</p>
<p><b>See also</b> <a href="qpen.html#capStyle">capStyle</a>() and
<a href="qpen.html#cap-style">Cap Style</a>.</p>


<h3 class="fn"><a name="setColor" />QPen.setColor (<i>self</i>, <a href="qcolor.html">QColor</a>&#160;<i>color</i>)</h3><p>Sets the color of this pen's brush to the given
<i>color</i>.</p>
<p><b>See also</b> <a href="qpen.html#setBrush">setBrush</a>() and
<a href="qpen.html#color">color</a>().</p>


<h3 class="fn"><a name="setCosmetic" />QPen.setCosmetic (<i>self</i>, bool&#160;<i>cosmetic</i>)</h3><p>Sets this pen to cosmetic or non-cosmetic, depending on the
value of <i>cosmetic</i>.</p>
<p><b>See also</b> <a href="qpen.html#isCosmetic">isCosmetic</a>().</p>


<h3 class="fn"><a name="setDashOffset" />QPen.setDashOffset (<i>self</i>, float&#160;<i>doffset</i>)</h3><p>Sets the dash offset (the starting point on the dash pattern)
for this pen to the <i>offset</i> specified. The offset is measured
in terms of the units used to specify the dash pattern.</p>
<table class="generic">
<tr class="odd" valign="top">
<td><img alt="" src="images/qpen-dashpattern.png" /></td>
<td>For example, a pattern where each stroke is four units long,
followed by a gap of two units, will begin with the stroke when
drawn as a line.
<p>However, if the dash offset is set to 4.0, any line drawn will
begin with the gap. Values of the offset up to 4.0 will cause part
of the stroke to be drawn first, and values of the offset between
4.0 and 6.0 will cause the line to begin with part of the gap.</p>
</td>
</tr>
</table>
<p><b>Note:</b> This implicitly converts the style of the pen to
<a href="qt.html#PenStyle-enum">Qt.CustomDashLine</a>.</p>
<p><b>See also</b> <a href="qpen.html#dashOffset">dashOffset</a>().</p>


<h3 class="fn"><a name="setDashPattern" />QPen.setDashPattern (<i>self</i>, list-of-float&#160;<i>pattern</i>)</h3><p>Sets the dash pattern for this pen to the given <i>pattern</i>.
This implicitly converts the style of the pen to <a href="qt.html#PenStyle-enum">Qt.CustomDashLine</a>.</p>
<p>The pattern must be specified as an even number of positive
entries where the entries 1, 3, 5... are the dashes and 2, 4, 6...
are the spaces. For example:</p>
<table class="generic" width="100%">
<tr class="odd" valign="top">
<td><img alt="" src="images/qpen-custom.png" /></td>
<td>
<pre class="cpp">
 <span class="type"><a href="qpen.html">QPen</a></span> pen;
 <span class="type"><a href="qvector.html">QVector</a></span><span class="operator">&lt;</span><span class="type"><a href="qtcore.html#qreal-typedef">qreal</a></span><span class="operator">&gt;</span> dashes;
 <span class="type"><a href="qtcore.html#qreal-typedef">qreal</a></span> space <span class="operator">=</span> <span class="number">4</span>;
 dashes <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="number">1</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> space <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="number">3</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> space <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="number">9</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> space
            <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="number">27</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> space <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="number">9</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> space;
 pen<span class="operator">.</span>setDashPattern(dashes);
</pre></td>
</tr>
</table>
<p>The dash pattern is specified in units of the pens width; e.g. a
dash of length 5 in width 10 is 50 pixels long. Note that a pen
with zero width is equivalent to a cosmetic pen with a width of 1
pixel.</p>
<p>Each dash is also subject to cap styles so a dash of 1 with
square cap set will extend 0.5 pixels out in each direction
resulting in a total width of 2.</p>
<p>Note that the default cap style is <a href="qt.html#PenCapStyle-enum">Qt.SquareCap</a>, meaning that a square
line end covers the end point and extends beyond it by half the
line width.</p>
<p><b>See also</b> <a href="qpen.html#setStyle">setStyle</a>(),
<a href="qpen.html#dashPattern">dashPattern</a>(), <a href="qpen.html#setCapStyle">setCapStyle</a>(), and <a href="qpen.html#setCosmetic">setCosmetic</a>().</p>


<h3 class="fn"><a name="setJoinStyle" />QPen.setJoinStyle (<i>self</i>, <a href="qt.html#PenJoinStyle-enum">Qt.PenJoinStyle</a>&#160;<i>pcs</i>)</h3><p>Sets the pen's join style to the given <i>style</i>. The default
value is <a href="qt.html#PenJoinStyle-enum">Qt.BevelJoin</a>.</p>
<p><b>See also</b> <a href="qpen.html#joinStyle">joinStyle</a>()
and <a href="qpen.html#join-style">Join Style</a>.</p>


<h3 class="fn"><a name="setMiterLimit" />QPen.setMiterLimit (<i>self</i>, float&#160;<i>limit</i>)</h3><p>Sets the miter limit of this pen to the given <i>limit</i>.</p>
<p class="centerAlign"><img alt="" src="images/qpen-miterlimit.png" /></p>
<p>The miter limit describes how far a miter join can extend from
the join point. This is used to reduce artifacts between line joins
where the lines are close to parallel.</p>
<p>This value does only have effect when the pen style is set to
<a href="qt.html#PenJoinStyle-enum">Qt.MiterJoin</a>. The value is
specified in units of the pen's width, e.g. a miter limit of 5 in
width 10 is 50 pixels long. The default miter limit is 2, i.e.
twice the pen width in pixels.</p>
<p><b>See also</b> <a href="qpen.html#miterLimit">miterLimit</a>(),
<a href="qpen.html#setJoinStyle">setJoinStyle</a>(), and <a href="qpen.html#join-style">Join Style</a>.</p>


<h3 class="fn"><a name="setStyle" />QPen.setStyle (<i>self</i>, <a href="qt.html#PenStyle-enum">Qt.PenStyle</a>)</h3><p>Sets the pen style to the given <i>style</i>.</p>
<p>See the <a href="qt.html#PenStyle-enum">Qt.PenStyle</a>
documentation for a list of the available styles. Since Qt 4.1 it
is also possible to specify a custom dash pattern using the
<a href="qpen.html#setDashPattern">setDashPattern</a>() function
which implicitly converts the style of the pen to <a href="qt.html#PenStyle-enum">Qt.CustomDashLine</a>.</p>
<p><b>Note:</b> This function resets the dash offset to zero.</p>
<p><b>See also</b> <a href="qpen.html#style">style</a>() and
<a href="qpen.html#pen-style">Pen Style</a>.</p>


<h3 class="fn"><a name="setWidth" />QPen.setWidth (<i>self</i>, int&#160;<i>width</i>)</h3><p>Sets the pen width to the given <i>width</i> in pixels with
integer precision.</p>
<p>A line width of zero indicates a cosmetic pen. This means that
the pen width is always drawn one pixel wide, independent of the
<a href="qpainter.html#coordinate-transformations">transformation</a> set
on the painter.</p>
<p>Setting a pen width with a negative value is not supported.</p>
<p><b>See also</b> <a href="qpen.html#setWidthF">setWidthF</a>()
and <a href="qpen.html#width">width</a>().</p>


<h3 class="fn"><a name="setWidthF" />QPen.setWidthF (<i>self</i>, float&#160;<i>width</i>)</h3><p>Sets the pen width to the given <i>width</i> in pixels with
floating point precision.</p>
<p>A line width of zero indicates a cosmetic pen. This means that
the pen width is always drawn one pixel wide, independent of the
<a href="qpainter.html#coordinate-transformations">transformation</a> on
the painter.</p>
<p>Setting a pen width with a negative value is not supported.</p>
<p><b>See also</b> <a href="qpen.html#setWidth">setWidth</a>() and
<a href="qpen.html#widthF">widthF</a>().</p>


<h3 class="fn"><a name="style" /><a href="qt.html#PenStyle-enum">Qt.PenStyle</a> QPen.style (<i>self</i>)</h3><p>Returns the pen style.</p>
<p><b>See also</b> <a href="qpen.html#setStyle">setStyle</a>() and
<a href="qpen.html#pen-style">Pen Style</a>.</p>


<h3 class="fn"><a name="swap" />QPen.swap (<i>self</i>, <a href="qpen.html">QPen</a>&#160;<i>other</i>)</h3><p>Swaps pen <i>other</i> with this pen. This operation is very
fast and never fails.</p>
<p>This function was introduced in Qt 4.8.</p>


<h3 class="fn"><a name="width" />int QPen.width (<i>self</i>)</h3><p>Returns the pen width with integer precision.</p>
<p><b>See also</b> <a href="qpen.html#setWidth">setWidth</a>() and
<a href="qpen.html#widthF">widthF</a>().</p>


<h3 class="fn"><a name="widthF" />float QPen.widthF (<i>self</i>)</h3><p>Returns the pen width with floating point precision.</p>
<p><b>See also</b> <a href="qpen.html#setWidthF">setWidthF</a>()
and <a href="qpen.html#width">width</a>().</p>


<h3 class="fn"><a name="__eq__" />bool QPen.__eq__ (<i>self</i>, <a href="qpen.html">QPen</a>&#160;<i>p</i>)</h3><h3 class="fn"><a name="__ne__" />bool QPen.__ne__ (<i>self</i>, <a href="qpen.html">QPen</a>&#160;<i>p</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.11.2 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://qt.digia.com">Digia</a> 2014</td><td align="right" width="25%">Qt&#160;4.8.6</td></tr></table></div></address></body></html>