qpen.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 286 行 · 第 1/2 页

HTML
286
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/kernel/qpainter.cpp:3067 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QPen Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><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><p>The QPen class defines how a QPainter should draw lines and outlinesof shapes.<a href="#details">More...</a><p><tt>#include &lt;<a href="qpen-h.html">qpen.h</a>&gt;</tt><p>Inherits <a href="qt.html">Qt</a>.<p><a href="qpen-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QPen"><b>QPen</b></a> ()</div></li><li><div class=fn><a href="#QPen-2"><b>QPen</b></a> ( PenStyle&nbsp;style )</div></li><li><div class=fn><a href="#QPen-3"><b>QPen</b></a> ( const&nbsp;QColor&nbsp;&amp;&nbsp;color, uint&nbsp;width = 0, PenStyle&nbsp;style = SolidLine )</div></li><li><div class=fn><a href="#QPen-4"><b>QPen</b></a> ( const&nbsp;QColor&nbsp;&amp;&nbsp;cl, uint&nbsp;w, PenStyle&nbsp;s, PenCapStyle&nbsp;c, PenJoinStyle&nbsp;j )</div></li><li><div class=fn><a href="#QPen-5"><b>QPen</b></a> ( const&nbsp;QPen&nbsp;&amp;&nbsp;p )</div></li><li><div class=fn><a href="#~QPen"><b>~QPen</b></a> ()</div></li><li><div class=fn>QPen &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QPen&nbsp;&amp;&nbsp;p )</div></li><li><div class=fn>PenStyle <a href="#style"><b>style</b></a> () const</div></li><li><div class=fn>void <a href="#setStyle"><b>setStyle</b></a> ( PenStyle&nbsp;s )</div></li><li><div class=fn>uint <a href="#width"><b>width</b></a> () const</div></li><li><div class=fn>void <a href="#setWidth"><b>setWidth</b></a> ( uint&nbsp;w )</div></li><li><div class=fn>const QColor &amp; <a href="#color"><b>color</b></a> () const</div></li><li><div class=fn>void <a href="#setColor"><b>setColor</b></a> ( const&nbsp;QColor&nbsp;&amp;&nbsp;c )</div></li><li><div class=fn>PenCapStyle <a href="#capStyle"><b>capStyle</b></a> () const</div></li><li><div class=fn>void <a href="#setCapStyle"><b>setCapStyle</b></a> ( PenCapStyle&nbsp;c )</div></li><li><div class=fn>PenJoinStyle <a href="#joinStyle"><b>joinStyle</b></a> () const</div></li><li><div class=fn>void <a href="#setJoinStyle"><b>setJoinStyle</b></a> ( PenJoinStyle&nbsp;j )</div></li><li><div class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const&nbsp;QPen&nbsp;&amp;&nbsp;p ) const</div></li><li><div class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const&nbsp;QPen&nbsp;&amp;&nbsp;p ) const</div></li></ul><h2>Related Functions</h2><ul><li><div class=fn>QDataStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, const&nbsp;QPen&nbsp;&amp;&nbsp;p )</div></li><li><div class=fn>QDataStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QPen&nbsp;&amp;&nbsp;p )</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>The QPen class defines how a <a href="qpainter.html">QPainter</a> should draw lines and outlinesof shapes.<p> <p> A pen has a style, width, color, cap style and join style.<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 tonot draw lines or outlines.<p> When drawing 1 pixel wide diagonal lines you can either use a veryfast algorithm (specified by a line width of 0, which is thedefault), or a slower but more accurate algorithm (specified by aline width of 1). For horizontal and vertical lines a line widthof 0 is the same as a line width of 1. The cap and join style haveno effect on 0-width lines.<p> The pen color defines the color of lines and text. The defaultline color is black. The <a href="qcolor.html">QColor</a> documentation lists predefinedcolors.<p> The cap style defines how the end points of lines are drawn. Thejoin style defines how the joins between two lines are drawn whenmultiple connected lines are drawn (QPainter::drawPolyLine()etc.). The cap and join styles only apply to wide lines, i.e. whenthe width is 1 or greater.<p> Use the <a href="qbrush.html">QBrush</a> class to specify fill styles.<p> Example:<pre>    <a href="qpainter.html">QPainter</a> painter;    QPen     pen( red, 2 );             // red solid line, 2 pixels wide    painter.<a href="qpainter.html#begin">begin</a>( &amp;anyPaintDevice );   // paint something    painter.<a href="qpainter.html#setPen">setPen</a>( pen );              // set the red, wide pen    painter.<a href="qpainter.html#drawRect">drawRect</a>( 40,30, 200,100 ); // draw a rectangle    painter.<a href="qpainter.html#setPen">setPen</a>( blue );             // set blue pen, 0 pixel width    painter.<a href="qpainter.html#drawLine">drawLine</a>( 40,30, 240,130 ); // draw a diagonal in rectangle    painter.<a href="qpainter.html#end">end</a>();                      // painting done    </pre> <p> See the <a href="qt.html#PenStyle-enum">Qt::PenStyle</a> enum type for a complete list of penstyles.<p> With reference to the end points of lines, for wide (non-0-width)pens it depends on the cap style whether the end point is drawn ornot. <a href="qpainter.html">QPainter</a> will try to make sure that the end point is drawnfor 0-width pens, but this cannot be absolutely guaranteed becausethe underlying drawing engine is free to use any (typicallyaccelerated) algorithm for drawing 0-width lines. On all testedsystems, however, the end point of at least all non-diagonal linesare drawn.<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>() canbe set in the constructor or later with <a href="#setColor">setColor</a>(), <a href="#setWidth">setWidth</a>(),<a href="#setStyle">setStyle</a>(), <a href="#setCapStyle">setCapStyle</a>() and <a href="#setJoinStyle">setJoinStyle</a>(). Pens may also becompared and streamed.<p> <center><img src="pen-styles.png" alt="Pen styles"></center> <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>.<hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QPen"></a>QPen::QPen ()</h3>Constructs a default black solid line pen with 0 width, whichrenders lines 1 pixel wide (fast diagonals).<h3 class=fn><a name="QPen-2"></a>QPen::QPen ( <a href="qt.html#PenStyle-enum">PenStyle</a>&nbsp;style )</h3>Constructs a black pen with 0 width (fast diagonals) and style <em>style</em>.<p> <p>See also <a href="#setStyle">setStyle</a>().<h3 class=fn><a name="QPen-3"></a>QPen::QPen ( const&nbsp;<a href="qcolor.html">QColor</a>&nbsp;&amp;&nbsp;color, uint&nbsp;width = 0, <a href="qt.html#PenStyle-enum">PenStyle</a>&nbsp;style = SolidLine )</h3>Constructs a pen with the specified <em>color</em>, <em>width</em> and <em>style</em>.<p> <p>See also <a href="#setWidth">setWidth</a>(), <a href="#setStyle">setStyle</a>() and <a href="#setColor">setColor</a>().<h3 class=fn><a name="QPen-4"></a>QPen::QPen ( const&nbsp;<a href="qcolor.html">QColor</a>&nbsp;&amp;&nbsp;cl, uint&nbsp;w, <a href="qt.html#PenStyle-enum">PenStyle</a>&nbsp;s, <a href="qt.html#PenCapStyle-enum">PenCapStyle</a>&nbsp;c, <a href="qt.html#PenJoinStyle-enum">PenJoinStyle</a>&nbsp;j )</h3>Constructs a pen with the specified color <em>cl</em> and width <em>w</em>.The pen style is set to <em>s</em>, the pen cap style to <em>c</em> and thepen join style to <em>j</em>.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?