1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QColor 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: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QColor Class Reference</h1><br clear="all">
<p>
The QColor class provides colors based on RGB.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qcolor-h.html">qcolor.h</a>></code>
<p><a href="qcolor-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn">enum<b>Spec</b>{Rgb, Hsv}</div>
<li><div class="fn"><a href="#66b6eb"><b>QColor</b></a>()</div>
<li><div class="fn"><a href="#a7a9f7"><b>QColor</b></a>(intr, intg, intb)</div>
<li><div class="fn"><a href="#a910bb"><b>QColor</b></a>(intx, inty, intz, Spec)</div>
<li><div class="fn"><a href="#a80cb6"><b>QColor</b></a>(QRgbrgb, uintpixel=0xffffffff)</div>
<li><div class="fn"><a href="#63f335"><b>QColor</b></a>(constQString&name)</div>
<li><div class="fn"><a href="#0fae5a"><b>QColor</b></a>(constchar*name)</div>
<li><div class="fn"><a href="#8548a2"><b>QColor</b></a>(constQColor&)</div>
<li><div class="fn">QColor&<a href="#2d6b11"><b>operator=</b></a>(constQColor&)</div>
<li><div class="fn">bool<a href="#5cd295"><b>isValid</b></a>()const</div>
<li><div class="fn">bool<a href="#e98c4b"><b>isDirty</b></a>()const</div>
<li><div class="fn">QString<a href="#fbadec"><b>name</b></a>()const</div>
<li><div class="fn">void<a href="#27b1ed"><b>setNamedColor</b></a>(constQString&name)</div>
<li><div class="fn">void<a href="#a038da"><b>rgb</b></a>(int*r, int*g, int*b)const</div>
<li><div class="fn">QRgb<a href="#700837"><b>rgb</b></a>()const</div>
<li><div class="fn">void<a href="#f7c2cf"><b>setRgb</b></a>(intr, intg, intb)</div>
<li><div class="fn">void<a href="#6dedb4"><b>setRgb</b></a>(QRgbrgb)</div>
<li><div class="fn">int<a href="#cb22b1"><b>red</b></a>()const</div>
<li><div class="fn">int<a href="#aeee9e"><b>green</b></a>()const</div>
<li><div class="fn">int<a href="#704c8a"><b>blue</b></a>()const</div>
<li><div class="fn">void<a href="#aad8bf"><b>hsv</b></a>(int*h, int*s, int*v)const</div>
<li><div class="fn">voidgetHsv(int&h, int&s, int&v)const<em>(obsolete)</em></div>
<li><div class="fn">void<a href="#e47175"><b>setHsv</b></a>(inth, ints, intv)</div>
<li><div class="fn">QColor<a href="#b8743e"><b>light</b></a>(intf=150)const</div>
<li><div class="fn">QColor<a href="#b8dbb6"><b>dark</b></a>(intf=200)const</div>
<li><div class="fn">bool<a href="#8401d5"><b>operator==</b></a>(constQColor&c)const</div>
<li><div class="fn">bool<a href="#f97b3c"><b>operator!=</b></a>(constQColor&c)const</div>
<li><div class="fn">uint<a href="#303a85"><b>alloc</b></a>()</div>
<li><div class="fn">uint<a href="#4cec2b"><b>pixel</b></a>()const</div>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class="fn">bool<a href="#522199"><b>lazyAlloc</b></a>()</div>
<li><div class="fn">void<a href="#1c5a05"><b>setLazyAlloc</b></a>(bool)</div>
<li><div class="fn">int<a href="#3f2f21"><b>maxColors</b></a>()</div>
<li><div class="fn">int<a href="#e9525c"><b>numBitPlanes</b></a>()</div>
<li><div class="fn">int<a href="#f6b5c7"><b>enterAllocContext</b></a>()</div>
<li><div class="fn">void<a href="#30fe87"><b>leaveAllocContext</b></a>()</div>
<li><div class="fn">int<a href="#a16a0f"><b>currentAllocContext</b></a>()</div>
<li><div class="fn">void<a href="#cc0257"><b>destroyAllocContext</b></a>(int)</div>
<li><div class="fn">void<a href="#fe133c"><b>initialize</b></a>()</div>
<li><div class="fn">void<a href="#f48b2a"><b>cleanup</b></a>()</div>
</ul>
<h2>Related Functions</h2>
(Note that these are not member functions.)
<ul>
<li>QDataStream & <a href="qcolor.html#0c1d8e"><b>operator>></b></a> (QDataStream & s, QColor & c)
<li>int <a href="qcolor.html#1cf303"><b>qGreen</b></a> (QRgb rgb)
<li>int <a href="qcolor.html#2f7325"><b>qRed</b></a> (QRgb rgb)
<li>int <a href="qcolor.html#4ec911"><b>qAlpha</b></a> (QRgb rgba)
<li>int <a href="qcolor.html#73d0dd"><b>qGray</b></a> (int r, int g, int b)
<li>QRgb <a href="qcolor.html#84f29a"><b>qRgba</b></a> (int r, int g, int b, int a)
<li>int <a href="qcolor.html#b1d136"><b>qGray</b></a> (qRgb rgb)
<li>QDataStream & <a href="qcolor.html#bb497e"><b>operator<<</b></a> (QDataStream & s, const QColor & c)
<li>int <a href="qcolor.html#c84970"><b>qBlue</b></a> (QRgb rgb)
<li>QRgb <a href="qcolor.html#dab147"><b>qRgb</b></a> (int r, int g, int b)
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QColor class provides colors based on RGB.
<p>
A color is normally specified in terms of RGB (red,green and blue)
components, but it is also possible to specify HSV (hue,saturation
and value) or set a color name (the names are copied from from the
X11 color database).
<p>In addition to the RGB value, a QColor also has a pixel value. This
value is used by the underlying window system to refer to a color. It
can be thought of as an index into the display hardware's color table.
<p>There are 19 predefined QColor objects: <code>black, white, darkGray, gray, lightGray, red, green, blue, cyan, magenta, yellow, darkRed, darkGreen, darkBlue, darkCyan, darkMagenta, darkYellow, color0</code> and <code>color1.</code>
<p>The colors <code>color0</code> (zero pixel value) and <code>color1</code> (non-zero
pixel value) are special colors for drawing in <a href="qbitmap.html">bitmaps</a>.
<p>The QColor class has an efficient, dynamic color allocation
strategy. A color is normally allocated the first time it is used
(lazy allocation), that is, whenever the <a href="#4cec2b">pixel</a>() function is called:
<p><ol>
<li>Is the pixel value valid? If it is, just return it, otherwise,
allocate a pixel value.
<li>Check an internal hash table to see if we allocated an equal RGB
value earlier. If we did, set the pixel value and return.
<li>Try to allocate the RGB value. If we succeed, we get a pixel value
which we save in the internal table with the RGB value.
Return the pixel value.
<li>The color could not be allocated. Find the closest matching
color and save it in the internal table.
</ol>
<p>Since many people don't know the HSV color model very well, we'll
cover it briefly here.
<p>The RGB model is hardware-oriented. Its representation is close to
what most monitors show. In contrast, HSV represents color in a way
more suited to traditional human perception of color. For example,
the relationships "stronger than", "darker than", "the opposite of"
are easily expressed in HSV, but are much harder to express in RGB.
<p>HSV, like RGB, has three components. They are: <ul> <li> H, for
hue, is either 0-360 if the color is chromatic (not gray), or
meaningless if it is gray. It represents degrees on the color wheel
familiar to most people. Red is 0 (degrees), green is 120 and blue
is 240. <li> S, for saturation, is 0-255 and the bigger it is, the
stronger the color is. Grayish colors have saturation near 0, very
strong colors have saturation near 255. <li> V, for value, is 0-255
and represents lightness or brightness of the color. 0 is black,
255 is far from black as possible. </ul>
<p>Here are some examples: Pure red is H=0, S=255, V=255. A dark red,
moving slightly towards the magenta, could be H=350 (equivalent to
-10), S=255, V=180. A grayish light red could have H about 0 (say
350-359 or 0-10), S about 50-100, and S=255.
<p>See also <a href="qpalette.html">QPalette</a>, <a href="qcolorgroup.html">QColorGroup</a>, <a href="qapplication.html#1ee2d1">QApplication::setColorSpec</a>() and <a href="http://www.inforamp.net/~poynton/Poynton-color.html">Color FAQ.</a>
<p>Examples:
<a href="grapher-grapher-cpp.html#QColor">grapher/grapher.cpp</a>
<a href="drawlines-connect-cpp.html#QColor">drawlines/connect.cpp</a>
<a href="i18n-main-cpp.html#QColor">i18n/main.cpp</a>
<a href="drawdemo-drawdemo-cpp.html#QColor">drawdemo/drawdemo.cpp</a>
<a href="progress-progress-cpp.html#QColor">progress/progress.cpp</a>
<a href="desktop-desktop-cpp.html#QColor">desktop/desktop.cpp</a>
<a href="picture-picture-cpp.html#QColor">picture/picture.cpp</a>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="66b6eb"></a>QColor::QColor()</h3>
<p>Constructs an invalid color with the RGB value (0,0,0). An invalid color
is a color that is not properly set up for the underlying window system.
<p>See also <a href="#5cd295">isValid</a>().
<h3 class="fn"><a name="a80cb6"></a>QColor::QColor(QRgbrgb, uintpixel=0xffffffff)</h3>
<p>Constructs a color with a RGB value and a custom pixel value.
<p>If the <em>pixel</em> = 0xffffffff, then the color uses the RGB value in a
standard way. If <em>pixel</em> is something else, then the pixel value will
be set directly to <em>pixel</em> (skips the normal allocation procedure).
<h3 class="fn"><a name="63f335"></a>QColor::QColor(const<a href="qstring.html">QString</a>&name)</h3>
<p>Constructs a named color in the same way as <a href="#27b1ed">setNamedColor</a>().
<p>See also <a href="#27b1ed">setNamedColor</a>().
<h3 class="fn"><a name="8548a2"></a>QColor::QColor(constQColor&c)</h3>
<p>Constructs a color that is a copy of <em>c.</em>
<h3 class="fn"><a name="0fae5a"></a>QColor::QColor(constchar*name)</h3>
<p>Constructs a named color in the same way as <a href="#27b1ed">setNamedColor</a>().
<p>See also <a href="#27b1ed">setNamedColor</a>().
<h3 class="fn"><a name="a7a9f7"></a>QColor::QColor(intr, intg, intb)</h3>
<p>Constructs a color with the RGB value <em>(r,g,b). r, g</em> and <em>b</em> must be in the range 0..255.
<p>See also <a href="#6dedb4">setRgb</a>().
<h3 class="fn"><a name="a910bb"></a>QColor::QColor(intx, inty, intz, SpeccolorSpec)</h3>
<p>Constructs a color with the RGB <em>or</em> HSV value <em>(x,y,z).</em>
<p>The <em>(x,y,z)</em> triplet defines an RGB value if <em>colorSpec</em> == <code>QColor::Rgb.</code> <em>x</em> (red), <em>y</em> (green) and <em>z</em> (blue) must be in the
range 0..255.
<p>The <em>(x,y,z)</em> triplet defines a HSV value if <em>colorSpec</em> == <code>QColor::Hsv.</code> <em>x</em> (hue) must be in the range -1..360 (-1 means
achromatic), and <em>y</em> (saturation) and <em>z</em> (value) must be in the range
0..255.
<p>See also <a href="#6dedb4">setRgb</a>() and <a href="#e47175">setHsv</a>().
<h3 class="fn">uint<a name="303a85"></a>QColor::alloc()</h3>
<p>Allocates the RGB color and returns the pixel value.
<p>Allocating a color means to obtain a pixel value from the RGB
specification. The pixel value is an index into the global color
table, but should be considered an arbitrary platform-dependent value.
<p>The <a href="#4cec2b">pixel</a>() function calls alloc() if necessary, so in general you
don't need to call this function.
<p>See also <a href="#1c5a05">setLazyAlloc</a>() and <a href="#f6b5c7">enterAllocContext</a>().
<h3 class="fn">int<a name="704c8a"></a>QColor::blue()const</h3>
<p>Returns the B (blue) component of the RGB value.
<h3 class="fn">void<a name="f48b2a"></a>QColor::cleanup() <code>[static]</code></h3>
<p>Internal clean up required for QColor.
This function is called from the <a href="qapplication.html">QApplication</a> destructor.
<p>See also <a href="#fe133c">initialize</a>().
<h3 class="fn">int<a name="a16a0f"></a>QColor::currentAllocContext() <code>[static]</code></h3>
<p>Returns the current color allocation context.
<p>The default context is 0.
<p>See also <a href="#f6b5c7">enterAllocContext</a>() and <a href="#30fe87">leaveAllocContext</a>().
<h3 class="fn">QColor<a name="b8dbb6"></a>QColor::dark(intfactor=200)const</h3>
<p>Returns a darker (or lighter) color.
<p>Returns a darker color if <em>factor</em> is greater than 100.
Setting <em>factor</em> to 300 returns a color that has
one third the brightness.
<p>Returns a lighter color if <em>factor</em> is less than 100, equal to
<a href="#b8743e">light</a>(10000 / <em>factor).</em>
<p>This function converts the current RGB color to HSV, divides V by
<em>factor</em> and converts back to RGB.
<p>See also <a href="#b8743e">light</a>().
<p>Examples:
<a href="desktop-desktop-cpp.html#dark">desktop/desktop.cpp</a>
<h3 class="fn">void<a name="cc0257"></a>QColor::destroyAllocContext(intcontext) <code>[static]</code></h3>
<p>Destroys a color allocation context, <em>context.</em>
<p>This function deallocates all colors that were allocated in the
specified <em>context.</em>
If <em>context</em> == -1, it frees up all colors
that the application has allocated.
If <em>context</em> == -2, it frees up all colors
that the application has allocated, except those in the
default context.
<p>The function does nothing for true color displays.
<p>See also <a href="#f6b5c7">enterAllocContext</a>() and <a href="#303a85">alloc</a>().
<h3 class="fn">int<a name="f6b5c7"></a>QColor::enterAllocContext() <code>[static]</code></h3>
<p>Enters a color allocation context and returns a nonzero unique identifier.
<p>Color allocation contexts are useful for programs that need to
allocate many colors and throw them away later, like image viewers.
The allocation context functions work for true color displays as
well as colormap display, except that <a href="#cc0257">QColor::destroyAllocContext</a>()
does nothing for true color.
<p>Example:
<pre> <a href="qpixmap.html">QPixmap</a> loadPixmap( <a href="qstring.html">QString</a> fileName )
{
static int alloc_context = 0;
if ( alloc_context )
<a href="#cc0257">QColor::destroyAllocContext</a>( alloc_context );
alloc_context = QColor::enterAllocContext();
<a href="qpixmap.html">QPixmap</a> pm( fileName );
<a href="#30fe87">QColor::leaveAllocContext</a>();
return pm;
}
</pre>
<p>The example code loads a pixmap from file. It frees up all colors
that were allocated the last time loadPixmap() was called.
<p>The initial/default context is 0. Qt keeps a list of colors
associated with their allocation contexts. You can call
<a href="#cc0257">destroyAllocContext</a>() to get rid of all colors that were allocated
in a specific context.
<p>Calling enterAllocContext() enters an allocation context. The
allocation context lasts until you call <a href="#30fe87">leaveAllocContext</a>(). QColor
has an internal stack of allocation contexts. Each call to
enterAllocContex() must have a corresponding leaveAllocContext().
<p><pre> // context 0 active
int c1 = QColor::enterAllocContext(); // enter context c1
// context c1 active
int c2 = QColor::enterAllocContext(); // enter context c2
// context c2 active
<a href="#30fe87">QColor::leaveAllocContext</a>(); // leave context c2
// context c1 active
<a href="#30fe87">QColor::leaveAllocContext</a>(); // leave context c1
// context 0 active
// Now, free all colors that were allocated in context c2
<a href="#cc0257">QColor::destroyAllocContext</a>( c2 );
</pre>
<p>You may also want to set the application's color specification.
See <a href="qapplication.html#1ee2d1">QApplication::setColorSpec</a>() for more information.
<p>See also <a href="#30fe87">leaveAllocContext</a>(), <a href="#a16a0f">currentAllocContext</a>(), <a href="#cc0257">destroyAllocContext</a>() and <a href="qapplication.html#1ee2d1">QApplication::setColorSpec</a>().
<h3 class="fn">void<a name="1791f6"></a>QColor::getHsv(int&h, int&s, int&v)const</h3>
<p><b>This function is obsolete.</b> It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.<p>
<h3 class="fn">int<a name="aeee9e"></a>QColor::green()const</h3>
<p>Returns the G (green) component of the RGB value.
<h3 class="fn">void<a name="aad8bf"></a>QColor::hsv(int*h, int*s, int*v)const</h3>
<p>Returns the current RGB value as HSV.
<p>Arguments:
<ul>
<li><em>*h,</em> hue.
<li><em>*s,</em> saturation.
<li><em>*v,</em> value.
</ul>
The hue defines the color. Its range is 0..359 if the color is chromatic
and -1 if the color is achromatic. The saturation and value both vary
between 0 and 255 inclusive.
<p>See also <a href="#e47175">setHsv</a>() and <a href="#700837">rgb</a>().
<h3 class="fn">void<a name="fe133c"></a>QColor::initialize() <code>[static]</code></h3>
<p>Internal initialization required for QColor.
This function is called from the <a href="qapplication.html">QApplication</a> constructor.
<p>See also <a href="#f48b2a">cleanup</a>().
<h3 class="fn">bool<a name="e98c4b"></a>QColor::isDirty()const</h3>
<p>Returns TRUE if the color is dirty, i.e. lazy allocation is enabled and
an RGB/HSV value has been set but not allocated.
<p>See also <a href="#1c5a05">setLazyAlloc</a>(), <a href="#303a85">alloc</a>() and <a href="#4cec2b">pixel</a>().
<h3 class="fn">bool<a name="5cd295"></a>QColor::isValid()const</h3>
<p>Returns FALSE if the color is invalid, i.e. it was constructed using the
default constructor.
<h3 class="fn">bool<a name="522199"></a>QColor::lazyAlloc() <code>[static]</code></h3>
<p>Returns TRUE if lazy color allocation is enabled (on-demand allocation),
or FALSE if it is disabled (immediate allocation).
<p>See also <a href="#1c5a05">setLazyAlloc</a>().
<h3 class="fn">void<a name="30fe87"></a>QColor::leaveAllocContext() <code>[static]</code></h3>
<p>Leaves a color allocation context.
<p>See <a href="#f6b5c7">enterAllocContext</a>() for a detailed explanation.
<p>See also <a href="#f6b5c7">enterAllocContext</a>() and <a href="#a16a0f">currentAllocContext</a>().
<h3 class="fn">QColor<a name="b8743e"></a>QColor::light(intfactor=150)const</h3>
<p>Returns a lighter (or darker) color.
<p>Returns a lighter color if <em>factor</em> is greater than 100.
Setting <em>factor</em> to 150 returns a color that is 50% brighter.
<p>Returns a darker color if <em>factor</em> is less than 100, equal to
<a href="#b8dbb6">dark</a>(10000 / <em>factor).</em>
<p>This function converts the current RGB color to HSV, multiplies V with
<em>factor</em> and converts back to RGB.
<p>See also <a href="#b8dbb6">dark</a>().
<p>Examples:
<a href="desktop-desktop-cpp.html#light">desktop/desktop.cpp</a>
<h3 class="fn">int<a name="3f2f21"></a>QColor::maxColors() <code>[static]</code></h3>
<p>Returns the maximum number of colors supported by the underlying window
system.
<h3 class="fn"><a href="qstring.html">QString</a><a name="fbadec"></a>QColor::name()const</h3>
<p>Returns the name of the color in the format #RRGGBB.
<p>See also <a href="#27b1ed">setNamedColor</a>().
<h3 class="fn">int<a name="e9525c"></a>QColor::numBitPlanes() <code>[static]</code></h3>
<p>Returns the number of color bit planes for the underlying window system.
<p>The returned values is equal to the default pixmap depth;
<p>See also <a href="qpixmap.html#e194ad">QPixmap::defaultDepth</a>().
<h3 class="fn">bool<a name="f97b3c"></a>QColor::operator!=(constQColor&c)const</h3>
<p>Returns TRUE if this color has different RGB value from <em>c,</em>
or FALSE if they have equal RGB values.
<h3 class="fn">QColor&<a name="2d6b11"></a>QColor::operator=(constQColor&c)</h3>
<p>Assigns a copy of the color <code>and</code> returns a reference to this color.
<h3 class="fn">bool<a name="8401d5"></a>QColor::operator==(constQColor&c)const</h3>
<p>Returns TRUE if this color has the same RGB value as <em>c,</em>
or FALSE if they have different RGB values.
<h3 class="fn">uint<a name="4cec2b"></a>QColor::pixel()const</h3>
<p>Returns the pixel value.
<p>This value is used by the underlying window system to refer to a color.
It can be thought of as an index into the display hardware's color table,
but the value is an arbitrary 32-bit value.
<p>See also <a href="#1c5a05">setLazyAlloc</a>() and <a href="#303a85">alloc</a>().
<h3 class="fn">int<a name="cb22b1"></a>QColor::red()const</h3>
<p>Returns the R (red) component of the RGB value.
<h3 class="fn">QRgb<a name="700837"></a>QColor::rgb()const</h3>
<p>Returns the RGB value.
<p>The return type <em>QRgb</em> is equivalent to <code>unsigned int.</code>
<p>See also <a href="#6dedb4">setRgb</a>(), <a href="#aad8bf">hsv</a>(), <a href="#2f7325">qRed</a>(), <a href="#c84970">qBlue</a>() and <a href="#1cf303">qGreen</a>().
<h3 class="fn">void<a name="a038da"></a>QColor::rgb(int*r, int*g, int*b)const</h3>
<p>Returns the red, green and blue components of the RGB value in
<em>*r, *g</em> and <em>*b.</em> The value range for a component is 0..255.
<p>See also <a href="#6dedb4">setRgb</a>() and <a href="#aad8bf">hsv</a>().
<h3 class="fn">void<a name="e47175"></a>QColor::setHsv(inth, ints, intv)</h3>
<p>Sets a HSV color value.
<p>Arguments:
<ul>
<li><em>h,</em> hue (-1,0..360). -1 means achromatic.
<li><em>s,</em> saturation (0..255).
<li><em>v,</em> value (0..255).
</ul>
<p>See also <a href="#aad8bf">hsv</a>() and <a href="#6dedb4">setRgb</a>().
<p>Examples:
<a href="grapher-grapher-cpp.html#setHsv">grapher/grapher.cpp</a>
<a href="drawdemo-drawdemo-cpp.html#setHsv">drawdemo/drawdemo.cpp</a>
<a href="progress-progress-cpp.html#setHsv">progress/progress.cpp</a>
<h3 class="fn">void<a name="1c5a05"></a>QColor::setLazyAlloc(boolenable) <code>[static]</code></h3>
<p>Enables or disables lazy color allocation.
<p>If lazy allocation is enabled, colors are allocated the first time they
are used (upon calling the <a href="#4cec2b">pixel</a>() function). If lazy allocation is
disabled, colors are allocated when they are constructed or when either
<a href="#6dedb4">setRgb</a>() or <a href="#e47175">setHsv</a>() is called.
<p>Lazy color allocation is enabled by default.
<p>See also <a href="#522199">lazyAlloc</a>(), <a href="#4cec2b">pixel</a>() and <a href="#303a85">alloc</a>().
<h3 class="fn">void<a name="27b1ed"></a>QColor::setNamedColor(const<a href="qstring.html">QString</a>&name)</h3>
<p>Sets the RGB value to that of the named color.
<p>The color name may be in one of five formats: <ul>
<li> #RGB (each of R, G and B is a single hex digit)
<li> #RRGGBB
<li> #RRRGGGBBB
<li> #RRRRGGGGBBBB
<li> A named from the X color database (rgb.txt), e.g.
"steelblue" or "gainsboro". These color names also work
under Qt for Windows.
</ul>
<h3 class="fn">void<a name="6dedb4"></a>QColor::setRgb(QRgbrgb)</h3>
<p>Sets the RGB value to <em>rgb.</em>
<p>The type <em>QRgb</em> is equivalent to <code>unsigned int.</code>
<p>See also <a href="#700837">rgb</a>() and <a href="#e47175">setHsv</a>().
<h3 class="fn">void<a name="f7c2cf"></a>QColor::setRgb(intr, intg, intb)</h3>
<p>Sets the RGB value to <em>(r,g,b). r, g</em> and <em>b</em> must be in the range 0..255.
<p>See also <a href="#700837">rgb</a>() and <a href="#e47175">setHsv</a>().
<hr><h2>Related Functions</h2>
<h3><a href="qdatastream.html">QDataStream</a> & <a name="0c1d8e"></a>operator>> (<a href="qdatastream.html">QDataStream</a> & s, QColor & c)</h3>
<p>Reads a color object from the stream.
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>
<h3>int <a name="1cf303"></a>qGreen (QRgb rgb)</h3>
<p>Returns the green component of the RGB triplet <em>rgb.</em>
<p>See also <a href="qcolor.html#dab147">qRgb</a>() and <a href="qcolor.html#aeee9e">QColor::green</a>().
<p>Examples:
<a href="qmag-qmag-cpp.html#qGreen">qmag/qmag.cpp</a>
<h3>int <a name="2f7325"></a>qRed (QRgb rgb)</h3>
<p>Returns the red component of the RGB triplet <em>rgb.</em>
<p>See also <a href="qcolor.html#dab147">qRgb</a>() and <a href="qcolor.html#cb22b1">QColor::red</a>().
<p>Examples:
<a href="qmag-qmag-cpp.html#qRed">qmag/qmag.cpp</a>
<h3>int <a name="4ec911"></a>qAlpha (QRgb rgba)</h3>
<p>Returns the alpha component of the RGBA quadruplet <em>rgb.</em>
<h3>int <a name="73d0dd"></a>qGray (int r, int g, int b)</h3>
<p>Returns a gray value 0..255 from the <em>(r,g,b)</em> triplet.
<p>The gray value is calculated using the formula:
<code>(r*11 + g*16 + b*5)/32</code>
<h3>QRgb <a name="84f29a"></a>qRgba (int r, int g, int b, int a)</h3>
<p>Returns the RGBA quadruplet <em>(r,g,b,a).</em>
<p>The return type <em>QRgb</em> is equivalent to <code>unsigned int.</code>
<p>See also <a href="qcolor.html#dab147">qRgb</a>(), <a href="qcolor.html#2f7325">qRed</a>(), <a href="qcolor.html#1cf303">qGreen</a>() and <a href="qcolor.html#c84970">qBlue</a>().
<h3>int <a name="b1d136"></a>qGray (qRgb rgb)</h3>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
<h3><a href="qdatastream.html">QDataStream</a> & <a name="bb497e"></a>operator<< (<a href="qdatastream.html">QDataStream</a> & s, const QColor & c)</h3>
<p>Writes a color object to the stream.
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>
<h3>int <a name="c84970"></a>qBlue (QRgb rgb)</h3>
<p>Returns the blue component of the RGB triplet <em>rgb.</em>
<p>See also <a href="qcolor.html#dab147">qRgb</a>() and <a href="qcolor.html#704c8a">QColor::blue</a>().
<p>Examples:
<a href="qmag-qmag-cpp.html#qBlue">qmag/qmag.cpp</a>
<h3>QRgb <a name="dab147"></a>qRgb (int r, int g, int b)</h3>
<p>Returns the RGB triplet <em>(r,g,b).</em>
<p>The return type <em>QRgb</em> is equivalent to <code>unsigned int.</code>
<p>See also <a href="qcolor.html#84f29a">qRgba</a>(), <a href="qcolor.html#2f7325">qRed</a>(), <a href="qcolor.html#1cf303">qGreen</a>() and <a href="qcolor.html#c84970">qBlue</a>().
<p>Examples:
<a href="desktop-desktop-cpp.html#qRgb">desktop/desktop.cpp</a>
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|