source: trunk/doc/html/qbrush.html@ 208

Last change on this file since 208 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 13.6 KB
Line 
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:3567 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QBrush Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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>QBrush Class Reference</h1>
33
34<p>The QBrush class defines the fill pattern of shapes drawn by a QPainter.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qbrush-h.html">qbrush.h</a>&gt;</tt>
37<p>Inherits <a href="qt.html">Qt</a>.
38<p><a href="qbrush-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QBrush"><b>QBrush</b></a> ()</li>
42<li class=fn><a href="#QBrush-2"><b>QBrush</b></a> ( BrushStyle&nbsp;style )</li>
43<li class=fn><a href="#QBrush-3"><b>QBrush</b></a> ( const&nbsp;QColor&nbsp;&amp;&nbsp;color, BrushStyle&nbsp;style = SolidPattern )</li>
44<li class=fn><a href="#QBrush-4"><b>QBrush</b></a> ( const&nbsp;QColor&nbsp;&amp;&nbsp;color, const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap )</li>
45<li class=fn><a href="#QBrush-5"><b>QBrush</b></a> ( const&nbsp;QBrush&nbsp;&amp;&nbsp;b )</li>
46<li class=fn><a href="#~QBrush"><b>~QBrush</b></a> ()</li>
47<li class=fn>QBrush &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QBrush&nbsp;&amp;&nbsp;b )</li>
48<li class=fn>BrushStyle <a href="#style"><b>style</b></a> () const</li>
49<li class=fn>void <a href="#setStyle"><b>setStyle</b></a> ( BrushStyle&nbsp;s )</li>
50<li class=fn>const QColor &amp; <a href="#color"><b>color</b></a> () const</li>
51<li class=fn>void <a href="#setColor"><b>setColor</b></a> ( const&nbsp;QColor&nbsp;&amp;&nbsp;c )</li>
52<li class=fn>QPixmap * <a href="#pixmap"><b>pixmap</b></a> () const</li>
53<li class=fn>void <a href="#setPixmap"><b>setPixmap</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap )</li>
54<li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const&nbsp;QBrush&nbsp;&amp;&nbsp;b ) const</li>
55<li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const&nbsp;QBrush&nbsp;&amp;&nbsp;b ) const</li>
56</ul>
57<h2>Related Functions</h2>
58<ul>
59<li class=fn>QDataStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, const&nbsp;QBrush&nbsp;&amp;&nbsp;b )</li>
60<li class=fn>QDataStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QBrush&nbsp;&amp;&nbsp;b )</li>
61</ul>
62<hr><a name="details"></a><h2>Detailed Description</h2>
63
64
65<p> The QBrush class defines the fill pattern of shapes drawn by a <a href="qpainter.html">QPainter</a>.
66<p>
67
68
69<p> A brush has a style and a color. One of the brush styles is a
70custom pattern, which is defined by a <a href="qpixmap.html">QPixmap</a>.
71<p> The brush style defines the fill pattern. The default brush style
72is <a href="qt.html#BrushStyle-enum">NoBrush</a> (depending on how you construct a brush). This style
73tells the painter to not fill shapes. The standard style for
74filling is <a href="qt.html#BrushStyle-enum">SolidPattern</a>.
75<p> The brush color defines the color of the fill pattern. The <a href="qcolor.html">QColor</a>
76documentation lists the predefined colors.
77<p> Use the <a href="qpen.html">QPen</a> class for specifying line/outline styles.
78<p> Example:
79<pre>
80 <a href="qpainter.html">QPainter</a> painter;
81 QBrush brush( yellow ); // yellow solid pattern
82 painter.<a href="qpainter.html#begin">begin</a>( &amp;anyPaintDevice ); // paint something
83 painter.<a href="qpainter.html#setBrush">setBrush</a>( brush ); // set the yellow brush
84 painter.<a href="qpainter.html#setPen">setPen</a>( <a href="qt.html#PenStyle-enum">NoPen</a> ); // do not draw outline
85 painter.<a href="qpainter.html#drawRect">drawRect</a>( 40,30, 200,100 ); // draw filled rectangle
86 painter.<a href="qpainter.html#setBrush">setBrush</a>( <a href="qt.html#BrushStyle-enum">NoBrush</a> ); // do not fill
87 painter.<a href="qpainter.html#setPen">setPen</a>( black ); // set black pen, 0 pixel width
88 painter.<a href="qpainter.html#drawRect">drawRect</a>( 10,10, 30,20 ); // draw rectangle outline
89 painter.<a href="qpainter.html#end">end</a>(); // painting done
90 </pre>
91
92<p> See the <a href="#setStyle">setStyle</a>() function for a complete list of brush styles.
93<p> <center><img src="brush-styles.png" alt="Brush Styles"></center>
94<p> <p>See also <a href="qpainter.html">QPainter</a>, <a href="qpainter.html#setBrush">QPainter::setBrush</a>(), <a href="qpainter.html#setBrushOrigin">QPainter::setBrushOrigin</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>.
95
96<hr><h2>Member Function Documentation</h2>
97<h3 class=fn><a name="QBrush"></a>QBrush::QBrush ()
98</h3>
99Constructs a default black brush with the style <a href="qt.html#BrushStyle-enum">NoBrush</a> (will
100not fill shapes).
101
102<h3 class=fn><a name="QBrush-2"></a>QBrush::QBrush ( <a href="qt.html#BrushStyle-enum">BrushStyle</a>&nbsp;style )
103</h3>
104Constructs a black brush with the style <em>style</em>.
105<p> <p>See also <a href="#setStyle">setStyle</a>().
106
107<h3 class=fn><a name="QBrush-3"></a>QBrush::QBrush ( const&nbsp;<a href="qcolor.html">QColor</a>&nbsp;&amp;&nbsp;color, <a href="qt.html#BrushStyle-enum">BrushStyle</a>&nbsp;style = SolidPattern )
108</h3>
109Constructs a brush with the color <em>color</em> and the style <em>style</em>.
110<p> <p>See also <a href="#setColor">setColor</a>() and <a href="#setStyle">setStyle</a>().
111
112<h3 class=fn><a name="QBrush-4"></a>QBrush::QBrush ( const&nbsp;<a href="qcolor.html">QColor</a>&nbsp;&amp;&nbsp;color, const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap )
113</h3>
114Constructs a brush with the color <em>color</em> and a custom pattern
115stored in <em>pixmap</em>.
116<p> The color will only have an effect for monochrome pixmaps, i.e.
117for <a href="qpixmap.html#depth">QPixmap::depth</a>() == 1.
118<p> Pixmap brushes are currently not supported when printing on X11.
119<p> <p>See also <a href="#setColor">setColor</a>() and <a href="#setPixmap">setPixmap</a>().
120
121<h3 class=fn><a name="QBrush-5"></a>QBrush::QBrush ( const&nbsp;<a href="qbrush.html">QBrush</a>&nbsp;&amp;&nbsp;b )
122</h3>
123Constructs a brush that is a <a href="shclass.html">shallow
124 copy</a> of <em>b</em>.
125
126<h3 class=fn><a name="~QBrush"></a>QBrush::~QBrush ()
127</h3>
128Destroys the brush.
129
130<h3 class=fn>const&nbsp;<a href="qcolor.html">QColor</a>&nbsp;&amp; <a name="color"></a>QBrush::color () const
131</h3>
132
133<p> Returns the brush color.
134<p> <p>See also <a href="#setColor">setColor</a>().
135
136<h3 class=fn>bool <a name="operator!-eq"></a>QBrush::operator!= ( const&nbsp;<a href="qbrush.html">QBrush</a>&nbsp;&amp;&nbsp;b ) const
137</h3>
138
139<p> Returns TRUE if the brush is different from <em>b</em>; otherwise
140returns FALSE.
141<p> Two brushes are different if they have different styles, colors or
142pixmaps.
143<p> <p>See also <a href="#operator-eq-eq">operator==</a>().
144
145<h3 class=fn><a href="qbrush.html">QBrush</a>&nbsp;&amp; <a name="operator-eq"></a>QBrush::operator= ( const&nbsp;<a href="qbrush.html">QBrush</a>&nbsp;&amp;&nbsp;b )
146</h3>
147Assigns <em>b</em> to this brush and returns a reference to this brush.
148
149<h3 class=fn>bool <a name="operator-eq-eq"></a>QBrush::operator== ( const&nbsp;<a href="qbrush.html">QBrush</a>&nbsp;&amp;&nbsp;b ) const
150</h3>
151Returns TRUE if the brush is equal to <em>b</em>; otherwise returns
152FALSE.
153<p> Two brushes are equal if they have equal styles, colors and
154pixmaps.
155<p> <p>See also <a href="#operator!-eq">operator!=</a>().
156
157<h3 class=fn><a href="qpixmap.html">QPixmap</a>&nbsp;* <a name="pixmap"></a>QBrush::pixmap () const
158</h3>
159
160<p> Returns a pointer to the custom brush pattern, or 0 if no custom
161brush pattern has been set.
162<p> <p>See also <a href="#setPixmap">setPixmap</a>().
163
164<p>Example: <a href="richtext-example.html#x460">richtext/richtext.cpp</a>.
165<h3 class=fn>void <a name="setColor"></a>QBrush::setColor ( const&nbsp;<a href="qcolor.html">QColor</a>&nbsp;&amp;&nbsp;c )
166</h3>
167Sets the brush color to <em>c</em>.
168<p> <p>See also <a href="#color">color</a>() and <a href="#setStyle">setStyle</a>().
169
170<p>Example: <a href="picture-example.html#x108">picture/picture.cpp</a>.
171<h3 class=fn>void <a name="setPixmap"></a>QBrush::setPixmap ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap )
172</h3>
173Sets the brush pixmap to <em>pixmap</em>. The style is set to <a href="qt.html#BrushStyle-enum">CustomPattern</a>.
174<p> The current brush color will only have an effect for monochrome
175pixmaps, i.e. for <a href="qpixmap.html#depth">QPixmap::depth</a>() == 1.
176<p> Pixmap brushes are currently not supported when printing on X11.
177<p> <p>See also <a href="#pixmap">pixmap</a>() and <a href="#color">color</a>().
178
179<p>Example: <a href="richtext-example.html#x461">richtext/richtext.cpp</a>.
180<h3 class=fn>void <a name="setStyle"></a>QBrush::setStyle ( <a href="qt.html#BrushStyle-enum">BrushStyle</a>&nbsp;s )
181</h3>
182Sets the brush style to <em>s</em>.
183<p> The brush styles are:
184<center><table cellpadding="4" cellspacing="2" border="0">
185<tr bgcolor="#a2c511"> <th valign="top">Pattern <th valign="top">Meaning
186<tr bgcolor="#f0f0f0"> <td valign="top">NoBrush <td valign="top">will not fill shapes (default).
187<tr bgcolor="#d0d0d0"> <td valign="top">SolidPattern <td valign="top">solid (100%) fill pattern.
188<tr bgcolor="#f0f0f0"> <td valign="top">Dense1Pattern <td valign="top" colspan="1" rowspan="1"> 94% fill pattern.
189<tr bgcolor="#d0d0d0"> <td valign="top">Dense2Pattern <td valign="top" colspan="1" rowspan="1"> 88% fill pattern.
190<tr bgcolor="#f0f0f0"> <td valign="top">Dense3Pattern <td valign="top" colspan="1" rowspan="1"> 63% fill pattern.
191<tr bgcolor="#d0d0d0"> <td valign="top">Dense4Pattern <td valign="top" colspan="1" rowspan="1"> 50% fill pattern.
192<tr bgcolor="#f0f0f0"> <td valign="top">Dense5Pattern <td valign="top" colspan="1" rowspan="1"> 37% fill pattern.
193<tr bgcolor="#d0d0d0"> <td valign="top">Dense6Pattern <td valign="top" colspan="1" rowspan="1"> 12% fill pattern.
194<tr bgcolor="#f0f0f0"> <td valign="top">Dense7Pattern <td valign="top" colspan="1" rowspan="1"> 6% fill pattern.
195<tr bgcolor="#d0d0d0"> <td valign="top">HorPattern <td valign="top">horizontal lines pattern.
196<tr bgcolor="#f0f0f0"> <td valign="top">VerPattern <td valign="top">vertical lines pattern.
197<tr bgcolor="#d0d0d0"> <td valign="top">CrossPattern <td valign="top">crossing lines pattern.
198<tr bgcolor="#f0f0f0"> <td valign="top">BDiagPattern <td valign="top">diagonal lines (directed /) pattern.
199<tr bgcolor="#d0d0d0"> <td valign="top">FDiagPattern <td valign="top">diagonal lines (directed &#92;) pattern.
200<tr bgcolor="#f0f0f0"> <td valign="top">DiagCrossPattern <td valign="top">diagonal crossing lines pattern.
201<tr bgcolor="#d0d0d0"> <td valign="top">CustomPattern <td valign="top">set when a pixmap pattern is being used.
202</table></center>
203<p> On Windows, dense and custom patterns cannot be transparent.
204<p> See the <a href="#details">Detailed Description</a> for a picture
205of all the styles.
206<p> <p>See also <a href="#style">style</a>().
207
208<h3 class=fn><a href="qt.html#BrushStyle-enum">BrushStyle</a> <a name="style"></a>QBrush::style () const
209</h3>
210
211<p> Returns the brush style.
212<p> <p>See also <a href="#setStyle">setStyle</a>().
213
214<hr><h2>Related Functions</h2>
215<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-lt-lt"></a>operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, const&nbsp;<a href="qbrush.html">QBrush</a>&nbsp;&amp;&nbsp;b )
216</h3>
217
218<p> Writes the brush <em>b</em> to the stream <em>s</em> and returns a reference
219to the stream.
220<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
221
222<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-gt-gt"></a>operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, <a href="qbrush.html">QBrush</a>&nbsp;&amp;&nbsp;b )
223</h3>
224
225<p> Reads the brush <em>b</em> from the stream <em>s</em> and returns a reference
226to the stream.
227<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
228
229<!-- eof -->
230<hr><p>
231This file is part of the <a href="index.html">Qt toolkit</a>.
232Copyright &copy; 1995-2007
233<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
234<table width=100% cellspacing=0 border=0><tr>
235<td>Copyright &copy; 2007
236<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
237<td align=right><div align=right>Qt 3.3.8</div>
238</table></div></address></body>
239</html>
Note: See TracBrowser for help on using the repository browser.