~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qpen.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/painting/qpen.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QPen Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QPen Class Reference</h1>
 
21
<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>
 
22
<pre>#include &lt;QPen&gt;</pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
 
23
<ul>
 
24
<li><a href="qpen-members.html">List of all members, including inherited members</a></li>
 
25
</ul>
 
26
<a name="public-functions"></a>
 
27
<h3>Public Functions</h3>
 
28
<ul>
 
29
<li><div class="fn"/><b><a href="qpen.html#QPen">QPen</a></b> ()</li>
 
30
<li><div class="fn"/><b><a href="qpen.html#QPen-2">QPen</a></b> ( Qt::PenStyle <i>style</i> )</li>
 
31
<li><div class="fn"/><b><a href="qpen.html#QPen-3">QPen</a></b> ( const QColor &amp; <i>color</i> )</li>
 
32
<li><div class="fn"/><b><a href="qpen.html#QPen-4">QPen</a></b> ( const QBrush &amp; <i>brush</i>, qreal <i>width</i>, Qt::PenStyle <i>s</i> = Qt::SolidLine, Qt::PenCapStyle <i>c</i> = Qt::SquareCap, Qt::PenJoinStyle <i>j</i> = Qt::BevelJoin )</li>
 
33
<li><div class="fn"/><b><a href="qpen.html#QPen-5">QPen</a></b> ( const QPen &amp; <i>p</i> )</li>
 
34
<li><div class="fn"/><b><a href="qpen.html#dtor.QPen">~QPen</a></b> ()</li>
 
35
<li><div class="fn"/>QBrush <b><a href="qpen.html#brush">brush</a></b> () const</li>
 
36
<li><div class="fn"/>Qt::PenCapStyle <b><a href="qpen.html#capStyle">capStyle</a></b> () const</li>
 
37
<li><div class="fn"/>QColor <b><a href="qpen.html#color">color</a></b> () const</li>
 
38
<li><div class="fn"/>bool <b><a href="qpen.html#isSolid">isSolid</a></b> () const</li>
 
39
<li><div class="fn"/>Qt::PenJoinStyle <b><a href="qpen.html#joinStyle">joinStyle</a></b> () const</li>
 
40
<li><div class="fn"/>void <b><a href="qpen.html#setBrush">setBrush</a></b> ( const QBrush &amp; <i>brush</i> )</li>
 
41
<li><div class="fn"/>void <b><a href="qpen.html#setCapStyle">setCapStyle</a></b> ( Qt::PenCapStyle <i>c</i> )</li>
 
42
<li><div class="fn"/>void <b><a href="qpen.html#setColor">setColor</a></b> ( const QColor &amp; <i>c</i> )</li>
 
43
<li><div class="fn"/>void <b><a href="qpen.html#setJoinStyle">setJoinStyle</a></b> ( Qt::PenJoinStyle <i>j</i> )</li>
 
44
<li><div class="fn"/>void <b><a href="qpen.html#setStyle">setStyle</a></b> ( Qt::PenStyle <i>s</i> )</li>
 
45
<li><div class="fn"/>void <b><a href="qpen.html#setWidth">setWidth</a></b> ( int <i>width</i> )</li>
 
46
<li><div class="fn"/>void <b><a href="qpen.html#setWidthF">setWidthF</a></b> ( qreal <i>width</i> )</li>
 
47
<li><div class="fn"/>Qt::PenStyle <b><a href="qpen.html#style">style</a></b> () const</li>
 
48
<li><div class="fn"/>int <b><a href="qpen.html#width">width</a></b> () const</li>
 
49
<li><div class="fn"/>qreal <b><a href="qpen.html#widthF">widthF</a></b> () const</li>
 
50
<li><div class="fn"/><b><a href="qpen.html#operator-QVariant">operator QVariant</a></b> () const</li>
 
51
<li><div class="fn"/>bool <b><a href="qpen.html#operator-not-eq">operator!=</a></b> ( const QPen &amp; <i>p</i> ) const</li>
 
52
<li><div class="fn"/>QPen &amp; <b><a href="qpen.html#operator-eq">operator=</a></b> ( const QPen &amp; <i>p</i> )</li>
 
53
<li><div class="fn"/>bool <b><a href="qpen.html#operator-eq-eq">operator==</a></b> ( const QPen &amp; <i>p</i> ) const</li>
 
54
</ul>
 
55
<a name="related-non-members"></a>
 
56
<h3>Related Non-Members</h3>
 
57
<ul>
 
58
<li><div class="fn"/>QDataStream &amp; <b><a href="qpen.html#operator-gt-gt-50">operator&gt;&gt;</a></b> ( QDataStream &amp; <i>s</i>, QPen &amp; <i>p</i> )</li>
 
59
</ul>
 
60
<a name="details"></a>
 
61
<hr />
 
62
<h2>Detailed Description</h2>
 
63
<p>The QPen class defines how a <a href="qpainter.html">QPainter</a> should draw lines and outlines of shapes.</p>
 
64
<p>A pen has a style, width, brush, cap style and join style.</p>
 
65
<p>The pen style defines the line type. The default pen style is <tt>Qt::SolidLine</tt>. Setting the style to <tt>Qt::NoPen</tt> tells the painter to not draw lines or outlines.</p>
 
66
<p>The pen brush defines the fill of lines and text. The default pen is a solid black brush. The <a href="qcolor.html">QColor</a> documentation lists predefined colors.</p>
 
67
<p>The cap style defines how the end points of lines are drawn. The join style defines how the joins between two lines are drawn when multiple connected lines are drawn (<a href="qpainter.html#drawPolyline">QPainter::drawPolyline</a>() etc.). The cap and join styles only apply to wide lines, i.e. when the width is 1 or greater.</p>
 
68
<p>Use the <a href="qbrush.html">QBrush</a> class to specify fill styles.</p>
 
69
<p>Example:</p>
 
70
<pre>&nbsp;           QPainter painter;
 
71
            QPen pen(Qt::red, 2);                 // red solid line, 2 pixels wide
 
72
            painter.begin(&amp;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(Qt::blue);             // set blue pen, 0 pixel width
 
76
            painter.drawLine(40,30, 240,130); // draw a diagonal in rectangle
 
77
            painter.end();                    // painting done</pre>
 
78
<p>See the <a href="qt.html#PenStyle-enum">Qt::PenStyle</a> enum type for a complete list of pen styles.</p>
 
79
<p>Whether or not end points are drawn when the pen width is zero or one depends on the cap style. Using SquareCap (the default) or RoundCap they are drawn, using FlatCap they are not drawn.</p>
 
80
<p>A pen's <a href="qpen.html#color">color</a>(), <a href="qpen.html#brush">brush</a>(), <a href="qpen.html#width">width</a>(), <a href="qpen.html#style">style</a>(), <a href="qpen.html#capStyle">capStyle</a>() and <a href="qpen.html#joinStyle">joinStyle</a>() can be set in the constructor or later with <a href="qpen.html#setColor">setColor</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>(). Pens may also be compared and streamed.</p>
 
81
<center><img src="images/pen-styles.png" alt="Pen styles" /></center><p>See also <a href="qpainter.html">QPainter</a> and <a href="qpainter.html#setPen">QPainter::setPen</a>().</p>
 
82
<hr />
 
83
<h2>Member Function Documentation</h2>
 
84
<h3 class="fn"><a name="QPen"></a>QPen::QPen ()</h3>
 
85
<p>Constructs a default black solid line pen with 0 width.</p>
 
86
<h3 class="fn"><a name="QPen-2"></a>QPen::QPen ( <a href="qt.html#PenStyle-enum">Qt::PenStyle</a> <i>style</i> )</h3>
 
87
<p>Constructs a black pen with 0 width and style <i>style</i>.</p>
 
88
<p>See also <a href="qpen.html#setStyle">setStyle</a>().</p>
 
89
<h3 class="fn"><a name="QPen-3"></a>QPen::QPen ( const <a href="qcolor.html">QColor</a> &amp; <i>color</i> )</h3>
 
90
<p>Constructs a pen of color <i>color</i> with 0 width.</p>
 
91
<p>See also <a href="qpen.html#setBrush">setBrush</a>() and <a href="qpen.html#setColor">setColor</a>().</p>
 
92
<h3 class="fn"><a name="QPen-4"></a>QPen::QPen ( const <a href="qbrush.html">QBrush</a> &amp; <i>brush</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>width</i>, <a href="qt.html#PenStyle-enum">Qt::PenStyle</a> <i>s</i> = Qt::SolidLine, <a href="qt.html#PenCapStyle-enum">Qt::PenCapStyle</a> <i>c</i> = Qt::SquareCap, <a href="qt.html#PenJoinStyle-enum">Qt::PenJoinStyle</a> <i>j</i> = Qt::BevelJoin )</h3>
 
93
<p>Constructs a pen with the specified brush <i>brush</i> and width <i>width</i>. The pen style is set to <i>s</i>, the pen cap style to <i>c</i> and the pen join style to <i>j</i>.</p>
 
94
<p>See also <a href="qpen.html#setWidth">setWidth</a>(), <a href="qpen.html#setStyle">setStyle</a>(), and <a href="qpen.html#setBrush">setBrush</a>().</p>
 
95
<h3 class="fn"><a name="QPen-5"></a>QPen::QPen ( const QPen &amp; <i>p</i> )</h3>
 
96
<p>Constructs a pen that is a copy of <i>p</i>.</p>
 
97
<h3 class="fn"><a name="dtor.QPen"></a>QPen::~QPen ()</h3>
 
98
<p>Destroys the pen.</p>
 
99
<h3 class="fn"><a name="brush"></a><a href="qbrush.html">QBrush</a> QPen::brush () const</h3>
 
100
<p>Returns the brush used to fill strokes generated with this pen.</p>
 
101
<h3 class="fn"><a name="capStyle"></a><a href="qt.html#PenCapStyle-enum">Qt::PenCapStyle</a> QPen::capStyle () const</h3>
 
102
<p>Returns the pen's cap style.</p>
 
103
<p>See also <a href="qpen.html#setCapStyle">setCapStyle</a>().</p>
 
104
<h3 class="fn"><a name="color"></a><a href="qcolor.html">QColor</a> QPen::color () const</h3>
 
105
<p>Returns the pen color.</p>
 
106
<p>See also <a href="qpen.html#setColor">setColor</a>().</p>
 
107
<h3 class="fn"><a name="isSolid"></a>bool QPen::isSolid () const</h3>
 
108
<p>Returns true if the pen has a solid fill</p>
 
109
<h3 class="fn"><a name="joinStyle"></a><a href="qt.html#PenJoinStyle-enum">Qt::PenJoinStyle</a> QPen::joinStyle () const</h3>
 
110
<p>Returns the pen's join style.</p>
 
111
<p>See also <a href="qpen.html#setJoinStyle">setJoinStyle</a>().</p>
 
112
<h3 class="fn"><a name="setBrush"></a>void QPen::setBrush ( const <a href="qbrush.html">QBrush</a> &amp; <i>brush</i> )</h3>
 
113
<p>Sets the brush used to fill strokes generated with this pen to the given <i>brush</i>.</p>
 
114
<h3 class="fn"><a name="setCapStyle"></a>void QPen::setCapStyle ( <a href="qt.html#PenCapStyle-enum">Qt::PenCapStyle</a> <i>c</i> )</h3>
 
115
<p>Sets the pen's cap style to <i>c</i>.</p>
 
116
<p>The default value is <tt>Qt::SquareCap</tt>.</p>
 
117
<center><img src="images/pen-cap-styles.png" alt="Pen Cap Styles" /></center><p>See also <a href="qpen.html#capStyle">capStyle</a>().</p>
 
118
<h3 class="fn"><a name="setColor"></a>void QPen::setColor ( const <a href="qcolor.html">QColor</a> &amp; <i>c</i> )</h3>
 
119
<p>Sets the pen color to <i>c</i>.</p>
 
120
<p>See also <a href="qpen.html#color">color</a>().</p>
 
121
<h3 class="fn"><a name="setJoinStyle"></a>void QPen::setJoinStyle ( <a href="qt.html#PenJoinStyle-enum">Qt::PenJoinStyle</a> <i>j</i> )</h3>
 
122
<p>Sets the pen's join style to <i>j</i>.</p>
 
123
<p>The default value is <tt>Qt::BevelJoin</tt>.</p>
 
124
<center><img src="images/pen-join-styles.png" alt="Pen Join Styles" /></center><p>See also <a href="qpen.html#joinStyle">joinStyle</a>().</p>
 
125
<h3 class="fn"><a name="setStyle"></a>void QPen::setStyle ( <a href="qt.html#PenStyle-enum">Qt::PenStyle</a> <i>s</i> )</h3>
 
126
<p>Sets the pen style to <i>s</i>.</p>
 
127
<p>See the <a href="qt.html#PenStyle-enum">Qt::PenStyle</a> documentation for a list of all the styles.</p>
 
128
<p>See also <a href="qpen.html#style">style</a>().</p>
 
129
<h3 class="fn"><a name="setWidth"></a>void QPen::setWidth ( int <i>width</i> )</h3>
 
130
<p>Sets the pen width to <i>width</i></p>
 
131
<p>A line width of zero indicates cosmetic pen. This means that the pen width is always drawn one pixel wide, independent of the transformation set on the painter.</p>
 
132
<p>Setting a pen width with a negative value is not supported.</p>
 
133
<p>See also <a href="qpen.html#setWidthF">setWidthF</a>() and <a href="qpen.html#width">width</a>().</p>
 
134
<h3 class="fn"><a name="setWidthF"></a>void QPen::setWidthF ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>width</i> )</h3>
 
135
<p>Sets the pen width to <i>width</i>.</p>
 
136
<p>See also <a href="qpen.html#setWidth">setWidth</a>() and <a href="qpen.html#widthF">widthF</a>().</p>
 
137
<h3 class="fn"><a name="style"></a><a href="qt.html#PenStyle-enum">Qt::PenStyle</a> QPen::style () const</h3>
 
138
<p>Returns the pen style.</p>
 
139
<p>See also <a href="qpen.html#setStyle">setStyle</a>().</p>
 
140
<h3 class="fn"><a name="width"></a>int QPen::width () const</h3>
 
141
<p>Returns the pen width with integer preceision.</p>
 
142
<p>See also <a href="qpen.html#setWidth">setWidth</a>().</p>
 
143
<h3 class="fn"><a name="widthF"></a><a href="qtglobal.html#qreal-typedef">qreal</a> QPen::widthF () const</h3>
 
144
<p>Returns the pen width with floating point precision.</p>
 
145
<p>See also <a href="qpen.html#setWidthF">setWidthF</a>() and <a href="qpen.html#width">width</a>().</p>
 
146
<h3 class="fn"><a name="operator-QVariant"></a>QPen::operator QVariant () const</h3>
 
147
<p>Returns the pen as a <a href="qvariant.html">QVariant</a></p>
 
148
<h3 class="fn"><a name="operator-not-eq"></a>bool QPen::operator!= ( const QPen &amp; <i>p</i> ) const</h3>
 
149
<p>Returns true if the pen is different from <i>p</i>; otherwise returns false.</p>
 
150
<p>Two pens are different if they have different styles, widths or colors.</p>
 
151
<p>See also <a href="qpen.html#operator-eq-eq">operator==</a>().</p>
 
152
<h3 class="fn"><a name="operator-eq"></a>QPen &amp; QPen::operator= ( const QPen &amp; <i>p</i> )</h3>
 
153
<p>Assigns <i>p</i> to this pen and returns a reference to this pen.</p>
 
154
<h3 class="fn"><a name="operator-eq-eq"></a>bool QPen::operator== ( const QPen &amp; <i>p</i> ) const</h3>
 
155
<p>Returns true if the pen is equal to <i>p</i>; otherwise returns false.</p>
 
156
<p>Two pens are equal if they have equal styles, widths and colors.</p>
 
157
<p>See also <a href="qpen.html#operator-not-eq">operator!=</a>().</p>
 
158
<hr />
 
159
<h2>Related Non-Members</h2>
 
160
<h3 class="fn"><a name="operator-gt-gt-50"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>s</i>, QPen &amp; <i>p</i> )</h3>
 
161
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
162
<p>Reads a pen from the stream <i>s</i> into <i>p</i> and returns a reference to the stream.</p>
 
163
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
 
164
<p /><address><hr /><div align="center">
 
165
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
166
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
167
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
168
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
169
</tr></table></div></address></body>
 
170
</html>