1QPen(3qt) QPen(3qt)
2
3
4
6 QPen - Defines how a QPainter should draw lines and outlines of shapes
7
9 #include <qpen.h>
10
11 Inherits Qt.
12
13 Public Members
14 QPen ()
15 QPen ( PenStyle style )
16 QPen ( const QColor & color, uint width = 0, PenStyle style = SolidLine
17 )
18 QPen ( const QColor & cl, uint w, PenStyle s, PenCapStyle c,
19 PenJoinStyle j )
20 QPen ( const QPen & p )
21 ~QPen ()
22 QPen & operator= ( const QPen & p )
23 PenStyle style () const
24 void setStyle ( PenStyle s )
25 uint width () const
26 void setWidth ( uint w )
27 const QColor & color () const
28 void setColor ( const QColor & c )
29 PenCapStyle capStyle () const
30 void setCapStyle ( PenCapStyle c )
31 PenJoinStyle joinStyle () const
32 void setJoinStyle ( PenJoinStyle j )
33 bool operator== ( const QPen & p ) const
34 bool operator!= ( const QPen & p ) const
35
37 QDataStream & operator<< ( QDataStream & s, const QPen & p )
38 QDataStream & operator>> ( QDataStream & s, QPen & p )
39
41 The QPen class defines how a QPainter should draw lines and outlines of
42 shapes.
43
44 A pen has a style, width, color, cap style and join style.
45
46 The pen style defines the line type. The default pen style is
47 Qt::SolidLine. Setting the style to NoPen tells the painter to not draw
48 lines or outlines.
49
50 When drawing 1 pixel wide diagonal lines you can either use a very fast
51 algorithm (specified by a line width of 0, which is the default), or a
52 slower but more accurate algorithm (specified by a line width of 1).
53 For horizontal and vertical lines a line width of 0 is the same as a
54 line width of 1. The cap and join style have no effect on 0-width
55 lines.
56
57 The pen color defines the color of lines and text. The default line
58 color is black. The QColor documentation lists predefined colors.
59
60 The cap style defines how the end points of lines are drawn. The join
61 style defines how the joins between two lines are drawn when multiple
62 connected lines are drawn (QPainter::drawPolyline() etc.). The cap and
63 join styles only apply to wide lines, i.e. when the width is 1 or
64 greater.
65
66 Use the QBrush class to specify fill styles.
67
68 Example:
69
70 QPainter painter;
71 QPen pen( red, 2 ); // red solid line, 2 pixels wide
72 painter.begin( &anyPaintDevice ); // paint something
73 painter.setPen( pen ); // set the red, wide pen
74 painter.drawRect( 40,30, 200,100 ); // draw a rectangle
75 painter.setPen( blue ); // set blue pen, 0 pixel width
76 painter.drawLine( 40,30, 240,130 ); // draw a diagonal in rectangle
77 painter.end(); // painting done
78
79 See the Qt::PenStyle enum type for a complete list of pen styles.
80
81 With reference to the end points of lines, for wide (non-0-width) pens
82 it depends on the cap style whether the end point is drawn or not.
83 QPainter will try to make sure that the end point is drawn for 0-width
84 pens, but this cannot be absolutely guaranteed because the underlying
85 drawing engine is free to use any (typically accelerated) algorithm for
86 drawing 0-width lines. On all tested systems, however, the end point of
87 at least all non-diagonal lines are drawn.
88
89 A pen's color(), width(), style(), capStyle() and joinStyle() can be
90 set in the constructor or later with setColor(), setWidth(),
91 setStyle(), setCapStyle() and setJoinStyle(). Pens may also be compared
92 and streamed.
93
94 <center>
95 [Image Omitted]
96
97 </center>
98
99 See also QPainter, QPainter::setPen(), Graphics Classes, Image
100 Processing Classes, and Implicitly and Explicitly Shared Classes.
101
104 Constructs a default black solid line pen with 0 width, which renders
105 lines 1 pixel wide (fast diagonals).
106
108 Constructs a black pen with 0 width (fast diagonals) and style style.
109
110 See also setStyle().
111
113 )
114 Constructs a pen with the specified color, width and style.
115
116 See also setWidth(), setStyle(), and setColor().
117
119 PenJoinStyle j )
120 Constructs a pen with the specified color cl and width w. The pen style
121 is set to s, the pen cap style to c and the pen join style to j.
122
123 A line width of 0 will produce a 1 pixel wide line using a fast
124 algorithm for diagonals. A line width of 1 will also produce a 1 pixel
125 wide line, but uses a slower more accurate algorithm for diagonals. For
126 horizontal and vertical lines a line width of 0 is the same as a line
127 width of 1. The cap and join style have no effect on 0-width lines.
128
129 See also setWidth(), setStyle(), and setColor().
130
132 Constructs a pen that is a copy of p.
133
135 Destroys the pen.
136
138 Returns the pen's cap style.
139
140 See also setCapStyle().
141
143 Returns the pen color.
144
145 See also setColor().
146
147 Example: scribble/scribble.h.
148
150 Returns the pen's join style.
151
152 See also setJoinStyle().
153
155 Returns TRUE if the pen is different from p; otherwise returns FALSE.
156
157 Two pens are different if they have different styles, widths or colors.
158
159 See also operator==().
160
162 Assigns p to this pen and returns a reference to this pen.
163
165 Returns TRUE if the pen is equal to p; otherwise returns FALSE.
166
167 Two pens are equal if they have equal styles, widths and colors.
168
169 See also operator!=().
170
172 Sets the pen's cap style to c.
173
174 The default value is FlatCap. The cap style has no effect on 0-width
175 pens.
176
177 <center>
178 [Image Omitted]
179
180 </center>
181
182 Warning: On Windows 95/98 and Macintosh, the cap style setting has no
183 effect. Wide lines are rendered as if the cap style was SquareCap.
184
185 See also capStyle().
186
187 Example: themes/wood.cpp.
188
190 Sets the pen color to c.
191
192 See also color().
193
194 Examples:
195
197 Sets the pen's join style to j.
198
199 The default value is MiterJoin. The join style has no effect on 0-width
200 pens.
201
202 <center>
203 [Image Omitted]
204
205 </center>
206
207 Warning: On Windows 95/98 and Macintosh, the join style setting has no
208 effect. Wide lines are rendered as if the join style was BevelJoin.
209
210 See also joinStyle().
211
212 Example: themes/wood.cpp.
213
215 Sets the pen style to s.
216
217 See the Qt::PenStyle documentation for a list of all the styles.
218
219 Warning: On Mac OS X the style setting (other than NoPen and SolidLine)
220 have no effect as they are not implemented by the underlying system.
221
222 Warning: On Windows 95/98, the style setting (other than NoPen and
223 SolidLine) has no effect for lines with width greater than 1.
224
225 See also style().
226
227 Example: chart/chartform_canvas.cpp.
228
230 Sets the pen width to w.
231
232 A line width of 0 will produce a 1 pixel wide line using a fast
233 algorithm for diagonals. A line width of 1 will also produce a 1 pixel
234 wide line, but uses a slower more accurate algorithm for diagonals. For
235 horizontal and vertical lines a line width of 0 is the same as a line
236 width of 1. The cap and join style have no effect on 0-width lines.
237
238 See also width().
239
240 Examples:
241
243 Returns the pen style.
244
245 See also setStyle().
246
248 Returns the pen width.
249
250 See also setWidth().
251
252 Example: scribble/scribble.h.
253
256 Writes the pen p to the stream s and returns a reference to the stream.
257
258 See also Format of the QDataStream operators.
259
261 Reads a pen from the stream s into p and returns a reference to the
262 stream.
263
264 See also Format of the QDataStream operators.
265
266
268 http://doc.trolltech.com/qpen.html
269 http://www.trolltech.com/faq/tech.html
270
272 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
273 license file included in the distribution for a complete license
274 statement.
275
277 Generated automatically from the source code.
278
280 If you find a bug in Qt, please report it as described in
281 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
282 help you. Thank you.
283
284 The definitive Qt documentation is provided in HTML format; it is
285 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
286 web browser. This man page is provided as a convenience for those users
287 who prefer man pages, although this format is not officially supported
288 by Trolltech.
289
290 If you find errors in this manual page, please report them to qt-
291 bugs@trolltech.com. Please include the name of the manual page
292 (qpen.3qt) and the Qt version (3.3.8).
293
294
295
296Trolltech AS 2 February 2007 QPen(3qt)