1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qpainter.cpp:3138 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QPen Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QPen Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QPen class defines how a QPainter should draw lines and outlines
|
---|
35 | of shapes.
|
---|
36 | <a href="#details">More...</a>
|
---|
37 | <p><tt>#include <<a href="qpen-h.html">qpen.h</a>></tt>
|
---|
38 | <p>Inherits <a href="qt.html">Qt</a>.
|
---|
39 | <p><a href="qpen-members.html">List of all member functions.</a>
|
---|
40 | <h2>Public Members</h2>
|
---|
41 | <ul>
|
---|
42 | <li class=fn><a href="#QPen"><b>QPen</b></a> ()</li>
|
---|
43 | <li class=fn><a href="#QPen-2"><b>QPen</b></a> ( PenStyle style )</li>
|
---|
44 | <li class=fn><a href="#QPen-3"><b>QPen</b></a> ( const QColor & color, uint width = 0, PenStyle style = SolidLine )</li>
|
---|
45 | <li class=fn><a href="#QPen-4"><b>QPen</b></a> ( const QColor & cl, uint w, PenStyle s, PenCapStyle c, PenJoinStyle j )</li>
|
---|
46 | <li class=fn><a href="#QPen-5"><b>QPen</b></a> ( const QPen & p )</li>
|
---|
47 | <li class=fn><a href="#~QPen"><b>~QPen</b></a> ()</li>
|
---|
48 | <li class=fn>QPen & <a href="#operator-eq"><b>operator=</b></a> ( const QPen & p )</li>
|
---|
49 | <li class=fn>PenStyle <a href="#style"><b>style</b></a> () const</li>
|
---|
50 | <li class=fn>void <a href="#setStyle"><b>setStyle</b></a> ( PenStyle s )</li>
|
---|
51 | <li class=fn>uint <a href="#width"><b>width</b></a> () const</li>
|
---|
52 | <li class=fn>void <a href="#setWidth"><b>setWidth</b></a> ( uint w )</li>
|
---|
53 | <li class=fn>const QColor & <a href="#color"><b>color</b></a> () const</li>
|
---|
54 | <li class=fn>void <a href="#setColor"><b>setColor</b></a> ( const QColor & c )</li>
|
---|
55 | <li class=fn>PenCapStyle <a href="#capStyle"><b>capStyle</b></a> () const</li>
|
---|
56 | <li class=fn>void <a href="#setCapStyle"><b>setCapStyle</b></a> ( PenCapStyle c )</li>
|
---|
57 | <li class=fn>PenJoinStyle <a href="#joinStyle"><b>joinStyle</b></a> () const</li>
|
---|
58 | <li class=fn>void <a href="#setJoinStyle"><b>setJoinStyle</b></a> ( PenJoinStyle j )</li>
|
---|
59 | <li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QPen & p ) const</li>
|
---|
60 | <li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QPen & p ) const</li>
|
---|
61 | </ul>
|
---|
62 | <h2>Related Functions</h2>
|
---|
63 | <ul>
|
---|
64 | <li class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QPen & p )</li>
|
---|
65 | <li class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QPen & p )</li>
|
---|
66 | </ul>
|
---|
67 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
68 |
|
---|
69 |
|
---|
70 | The QPen class defines how a <a href="qpainter.html">QPainter</a> should draw lines and outlines
|
---|
71 | of shapes.
|
---|
72 | <p>
|
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 | <p> A pen has a style, width, color, cap style and join style.
|
---|
77 | <p> The pen style defines the line type. The default pen style is <a href="qt.html#PenStyle-enum">Qt::SolidLine</a>. Setting the style to <a href="qt.html#PenStyle-enum">NoPen</a> tells the painter to
|
---|
78 | not draw lines or outlines.
|
---|
79 | <p> When drawing 1 pixel wide diagonal lines you can either use a very
|
---|
80 | fast algorithm (specified by a line width of 0, which is the
|
---|
81 | default), or a slower but more accurate algorithm (specified by a
|
---|
82 | line width of 1). For horizontal and vertical lines a line width
|
---|
83 | of 0 is the same as a line width of 1. The cap and join style have
|
---|
84 | no effect on 0-width lines.
|
---|
85 | <p> The pen color defines the color of lines and text. The default
|
---|
86 | line color is black. The <a href="qcolor.html">QColor</a> documentation lists predefined
|
---|
87 | colors.
|
---|
88 | <p> The cap style defines how the end points of lines are drawn. The
|
---|
89 | join style defines how the joins between two lines are drawn when
|
---|
90 | multiple connected lines are drawn (<a href="qpainter.html#drawPolyline">QPainter::drawPolyline</a>()
|
---|
91 | etc.). The cap and join styles only apply to wide lines, i.e. when
|
---|
92 | the width is 1 or greater.
|
---|
93 | <p> Use the <a href="qbrush.html">QBrush</a> class to specify fill styles.
|
---|
94 | <p> Example:
|
---|
95 | <pre>
|
---|
96 | <a href="qpainter.html">QPainter</a> painter;
|
---|
97 | QPen pen( red, 2 ); // red solid line, 2 pixels wide
|
---|
98 | painter.<a href="qpainter.html#begin">begin</a>( &anyPaintDevice ); // paint something
|
---|
99 | painter.<a href="qpainter.html#setPen">setPen</a>( pen ); // set the red, wide pen
|
---|
100 | painter.<a href="qpainter.html#drawRect">drawRect</a>( 40,30, 200,100 ); // draw a rectangle
|
---|
101 | painter.<a href="qpainter.html#setPen">setPen</a>( blue ); // set blue pen, 0 pixel width
|
---|
102 | painter.<a href="qpainter.html#drawLine">drawLine</a>( 40,30, 240,130 ); // draw a diagonal in rectangle
|
---|
103 | painter.<a href="qpainter.html#end">end</a>(); // painting done
|
---|
104 | </pre>
|
---|
105 |
|
---|
106 | <p> See the <a href="qt.html#PenStyle-enum">Qt::PenStyle</a> enum type for a complete list of pen
|
---|
107 | styles.
|
---|
108 | <p> With reference to the end points of lines, for wide (non-0-width)
|
---|
109 | pens it depends on the cap style whether the end point is drawn or
|
---|
110 | not. <a href="qpainter.html">QPainter</a> will try to make sure that the end point is drawn
|
---|
111 | for 0-width pens, but this cannot be absolutely guaranteed because
|
---|
112 | the underlying drawing engine is free to use any (typically
|
---|
113 | accelerated) algorithm for drawing 0-width lines. On all tested
|
---|
114 | systems, however, the end point of at least all non-diagonal lines
|
---|
115 | are drawn.
|
---|
116 | <p> A pen's <a href="#color">color</a>(), <a href="#width">width</a>(), <a href="#style">style</a>(), <a href="#capStyle">capStyle</a>() and <a href="#joinStyle">joinStyle</a>() can
|
---|
117 | be set in the constructor or later with <a href="#setColor">setColor</a>(), <a href="#setWidth">setWidth</a>(),
|
---|
118 | <a href="#setStyle">setStyle</a>(), <a href="#setCapStyle">setCapStyle</a>() and <a href="#setJoinStyle">setJoinStyle</a>(). Pens may also be
|
---|
119 | compared and streamed.
|
---|
120 | <p> <center><img src="pen-styles.png" alt="Pen styles"></center>
|
---|
121 | <p> <p>See also <a href="qpainter.html">QPainter</a>, <a href="qpainter.html#setPen">QPainter::setPen</a>(), <a href="graphics.html">Graphics Classes</a>, <a href="images.html">Image Processing Classes</a>, and <a href="shared.html">Implicitly and Explicitly Shared Classes</a>.
|
---|
122 |
|
---|
123 | <hr><h2>Member Function Documentation</h2>
|
---|
124 | <h3 class=fn><a name="QPen"></a>QPen::QPen ()
|
---|
125 | </h3>
|
---|
126 | Constructs a default black solid line pen with 0 width, which
|
---|
127 | renders lines 1 pixel wide (fast diagonals).
|
---|
128 |
|
---|
129 | <h3 class=fn><a name="QPen-2"></a>QPen::QPen ( <a href="qt.html#PenStyle-enum">PenStyle</a> style )
|
---|
130 | </h3>
|
---|
131 | Constructs a black pen with 0 width (fast diagonals) and style <em>style</em>.
|
---|
132 | <p> <p>See also <a href="#setStyle">setStyle</a>().
|
---|
133 |
|
---|
134 | <h3 class=fn><a name="QPen-3"></a>QPen::QPen ( const <a href="qcolor.html">QColor</a> & color, uint width = 0, <a href="qt.html#PenStyle-enum">PenStyle</a> style = SolidLine )
|
---|
135 | </h3>
|
---|
136 | Constructs a pen with the specified <em>color</em>, <em>width</em> and <em>style</em>.
|
---|
137 | <p> <p>See also <a href="#setWidth">setWidth</a>(), <a href="#setStyle">setStyle</a>(), and <a href="#setColor">setColor</a>().
|
---|
138 |
|
---|
139 | <h3 class=fn><a name="QPen-4"></a>QPen::QPen ( const <a href="qcolor.html">QColor</a> & cl, uint w, <a href="qt.html#PenStyle-enum">PenStyle</a> s, <a href="qt.html#PenCapStyle-enum">PenCapStyle</a> c, <a href="qt.html#PenJoinStyle-enum">PenJoinStyle</a> j )
|
---|
140 | </h3>
|
---|
141 | Constructs a pen with the specified color <em>cl</em> and width <em>w</em>.
|
---|
142 | The pen style is set to <em>s</em>, the pen cap style to <em>c</em> and the
|
---|
143 | pen join style to <em>j</em>.
|
---|
144 | <p> A line width of 0 will produce a 1 pixel wide line using a fast
|
---|
145 | algorithm for diagonals. A line width of 1 will also produce a 1
|
---|
146 | pixel wide line, but uses a slower more accurate algorithm for
|
---|
147 | diagonals. For horizontal and vertical lines a line width of 0 is
|
---|
148 | the same as a line width of 1. The cap and join style have no
|
---|
149 | effect on 0-width lines.
|
---|
150 | <p> <p>See also <a href="#setWidth">setWidth</a>(), <a href="#setStyle">setStyle</a>(), and <a href="#setColor">setColor</a>().
|
---|
151 |
|
---|
152 | <h3 class=fn><a name="QPen-5"></a>QPen::QPen ( const <a href="qpen.html">QPen</a> & p )
|
---|
153 | </h3>
|
---|
154 | Constructs a pen that is a copy of <em>p</em>.
|
---|
155 |
|
---|
156 | <h3 class=fn><a name="~QPen"></a>QPen::~QPen ()
|
---|
157 | </h3>
|
---|
158 | Destroys the pen.
|
---|
159 |
|
---|
160 | <h3 class=fn><a href="qt.html#PenCapStyle-enum">PenCapStyle</a> <a name="capStyle"></a>QPen::capStyle () const
|
---|
161 | </h3>
|
---|
162 | Returns the pen's cap style.
|
---|
163 | <p> <p>See also <a href="#setCapStyle">setCapStyle</a>().
|
---|
164 |
|
---|
165 | <h3 class=fn>const <a href="qcolor.html">QColor</a> & <a name="color"></a>QPen::color () const
|
---|
166 | </h3>
|
---|
167 |
|
---|
168 | <p> Returns the pen color.
|
---|
169 | <p> <p>See also <a href="#setColor">setColor</a>().
|
---|
170 |
|
---|
171 | <p>Example: <a href="scribble-example.html#x902">scribble/scribble.h</a>.
|
---|
172 | <h3 class=fn><a href="qt.html#PenJoinStyle-enum">PenJoinStyle</a> <a name="joinStyle"></a>QPen::joinStyle () const
|
---|
173 | </h3>
|
---|
174 | Returns the pen's join style.
|
---|
175 | <p> <p>See also <a href="#setJoinStyle">setJoinStyle</a>().
|
---|
176 |
|
---|
177 | <h3 class=fn>bool <a name="operator!-eq"></a>QPen::operator!= ( const <a href="qpen.html">QPen</a> & p ) const
|
---|
178 | </h3>
|
---|
179 |
|
---|
180 | <p> Returns TRUE if the pen is different from <em>p</em>; otherwise returns
|
---|
181 | FALSE.
|
---|
182 | <p> Two pens are different if they have different styles, widths or
|
---|
183 | colors.
|
---|
184 | <p> <p>See also <a href="#operator-eq-eq">operator==</a>().
|
---|
185 |
|
---|
186 | <h3 class=fn><a href="qpen.html">QPen</a> & <a name="operator-eq"></a>QPen::operator= ( const <a href="qpen.html">QPen</a> & p )
|
---|
187 | </h3>
|
---|
188 | Assigns <em>p</em> to this pen and returns a reference to this pen.
|
---|
189 |
|
---|
190 | <h3 class=fn>bool <a name="operator-eq-eq"></a>QPen::operator== ( const <a href="qpen.html">QPen</a> & p ) const
|
---|
191 | </h3>
|
---|
192 | Returns TRUE if the pen is equal to <em>p</em>; otherwise returns FALSE.
|
---|
193 | <p> Two pens are equal if they have equal styles, widths and colors.
|
---|
194 | <p> <p>See also <a href="#operator!-eq">operator!=</a>().
|
---|
195 |
|
---|
196 | <h3 class=fn>void <a name="setCapStyle"></a>QPen::setCapStyle ( <a href="qt.html#PenCapStyle-enum">PenCapStyle</a> c )
|
---|
197 | </h3>
|
---|
198 | Sets the pen's cap style to <em>c</em>.
|
---|
199 | <p> The default value is <a href="qt.html#PenCapStyle-enum">FlatCap</a>. The cap style has no effect on
|
---|
200 | 0-width pens.
|
---|
201 | <p> <center><img src="pen-cap-styles.png" alt="Pen Cap Styles"></center>
|
---|
202 | <p> <b>Warning:</b> On Windows 95/98 and Macintosh, the cap style setting has
|
---|
203 | no effect. Wide lines are rendered as if the cap style was <a href="qt.html#PenCapStyle-enum">SquareCap</a>.
|
---|
204 | <p> <p>See also <a href="#capStyle">capStyle</a>().
|
---|
205 |
|
---|
206 | <p>Example: <a href="themes-example.html#x226">themes/wood.cpp</a>.
|
---|
207 | <h3 class=fn>void <a name="setColor"></a>QPen::setColor ( const <a href="qcolor.html">QColor</a> & c )
|
---|
208 | </h3>
|
---|
209 | Sets the pen color to <em>c</em>.
|
---|
210 | <p> <p>See also <a href="#color">color</a>().
|
---|
211 |
|
---|
212 | <p>Examples: <a href="progress-example.html#x79">progress/progress.cpp</a> and <a href="scribble-example.html#x903">scribble/scribble.h</a>.
|
---|
213 | <h3 class=fn>void <a name="setJoinStyle"></a>QPen::setJoinStyle ( <a href="qt.html#PenJoinStyle-enum">PenJoinStyle</a> j )
|
---|
214 | </h3>
|
---|
215 | Sets the pen's join style to <em>j</em>.
|
---|
216 | <p> The default value is <a href="qt.html#PenJoinStyle-enum">MiterJoin</a>. The join style has no effect on
|
---|
217 | 0-width pens.
|
---|
218 | <p> <center><img src="pen-join-styles.png" alt="Pen Join Styles"></center>
|
---|
219 | <p> <b>Warning:</b> On Windows 95/98 and Macintosh, the join style setting
|
---|
220 | has no effect. Wide lines are rendered as if the join style was <a href="qt.html#PenJoinStyle-enum">BevelJoin</a>.
|
---|
221 | <p> <p>See also <a href="#joinStyle">joinStyle</a>().
|
---|
222 |
|
---|
223 | <p>Example: <a href="themes-example.html#x227">themes/wood.cpp</a>.
|
---|
224 | <h3 class=fn>void <a name="setStyle"></a>QPen::setStyle ( <a href="qt.html#PenStyle-enum">PenStyle</a> s )
|
---|
225 | </h3>
|
---|
226 | Sets the pen style to <em>s</em>.
|
---|
227 | <p> See the <a href="qt.html#PenStyle-enum">Qt::PenStyle</a> documentation for a list of all the
|
---|
228 | styles.
|
---|
229 | <p> <b>Warning:</b> On Mac OS X the style setting (other than <a href="qt.html#PenStyle-enum">NoPen</a> and <a href="qt.html#PenStyle-enum">SolidLine</a>) have no effect as they are not implemented by the
|
---|
230 | underlying system.
|
---|
231 | <p> <b>Warning:</b> On Windows 95/98, the style setting (other than <a href="qt.html#PenStyle-enum">NoPen</a>
|
---|
232 | and <a href="qt.html#PenStyle-enum">SolidLine</a>) has no effect for lines with width greater than
|
---|
233 | 1.
|
---|
234 | <p> <p>See also <a href="#style">style</a>().
|
---|
235 |
|
---|
236 | <p>Example: <a href="tutorial2-06.html#x2575">chart/chartform_canvas.cpp</a>.
|
---|
237 | <h3 class=fn>void <a name="setWidth"></a>QPen::setWidth ( uint w )
|
---|
238 | </h3>
|
---|
239 | Sets the pen width to <em>w</em>.
|
---|
240 | <p> A line width of 0 will produce a 1 pixel wide line using a fast
|
---|
241 | algorithm for diagonals. A line width of 1 will also produce a 1
|
---|
242 | pixel wide line, but uses a slower more accurate algorithm for
|
---|
243 | diagonals. For horizontal and vertical lines a line width of 0 is
|
---|
244 | the same as a line width of 1. The cap and join style have no
|
---|
245 | effect on 0-width lines.
|
---|
246 | <p> <p>See also <a href="#width">width</a>().
|
---|
247 |
|
---|
248 | <p>Examples: <a href="qaxserver-example-multiple.html#x2548">multiple/ax2.h</a>, <a href="progress-example.html#x80">progress/progress.cpp</a>, and <a href="scribble-example.html#x904">scribble/scribble.h</a>.
|
---|
249 | <h3 class=fn><a href="qt.html#PenStyle-enum">PenStyle</a> <a name="style"></a>QPen::style () const
|
---|
250 | </h3>
|
---|
251 |
|
---|
252 | <p> Returns the pen style.
|
---|
253 | <p> <p>See also <a href="#setStyle">setStyle</a>().
|
---|
254 |
|
---|
255 | <h3 class=fn>uint <a name="width"></a>QPen::width () const
|
---|
256 | </h3>
|
---|
257 |
|
---|
258 | <p> Returns the pen width.
|
---|
259 | <p> <p>See also <a href="#setWidth">setWidth</a>().
|
---|
260 |
|
---|
261 | <p>Example: <a href="scribble-example.html#x905">scribble/scribble.h</a>.
|
---|
262 | <hr><h2>Related Functions</h2>
|
---|
263 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-lt-lt"></a>operator<< ( <a href="qdatastream.html">QDataStream</a> & s, const <a href="qpen.html">QPen</a> & p )
|
---|
264 | </h3>
|
---|
265 |
|
---|
266 | <p> Writes the pen <em>p</em> to the stream <em>s</em> and returns a reference to
|
---|
267 | the stream.
|
---|
268 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
269 |
|
---|
270 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qpen.html">QPen</a> & p )
|
---|
271 | </h3>
|
---|
272 |
|
---|
273 | <p> Reads a pen from the stream <em>s</em> into <em>p</em> and returns a reference
|
---|
274 | to the stream.
|
---|
275 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
276 |
|
---|
277 | <!-- eof -->
|
---|
278 | <hr><p>
|
---|
279 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
280 | Copyright © 1995-2007
|
---|
281 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
282 | <table width=100% cellspacing=0 border=0><tr>
|
---|
283 | <td>Copyright © 2007
|
---|
284 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
285 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
286 | </table></div></address></body>
|
---|
287 | </html>
|
---|