1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the painting module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
31
#include "qnamespace.h"
32
#include "qcolormap.h"
33
#include "qdatastream.h"
44
\brief The QColor class provides colors based on RGB or HSV values.
50
A color is normally specified in terms of RGB (red, green, and blue)
51
components, but it is also possible to specify HSV (hue, saturation,
52
and value) or set a color name (the names are copied from from the
55
QColor's validity (isValid()) indicates whether it is legal at
56
all. For example, a RGB color with RGB values out of range is
57
illegal. For performance reasons, QColor mostly disregards illegal
58
colors. Therefore, the result of using an invalid color is undefined.
60
There are 20 predefined QColor objects: \c white, \c black, \c
61
red, \c darkRed, \c green, \c darkGreen, \c blue, \c darkBlue, \c
62
cyan, \c darkCyan, \c magenta, \c darkMagenta, \c yellow, \c
63
darkYellow, \c gray, \c darkGray, \c lightGray, \c color0, \c
64
color1, and \c transparent, accessible as members of the Qt
65
namespace (i.e. \c Qt::red).
67
\img qt-colors.png Qt Colors
69
The colors \c Qt::color0 (zero pixel value) and \c Qt::color1 (non-zero
70
pixel value) are special colors for drawing in QBitmaps. Painting with \c
71
Qt::color0 sets the bitmap bits to 0 (transparent, i.e. background), and
72
painting with \c Qt::color1 sets the bits to 1 (opaque, i.e. foreground).
74
QColor is platform and device independent. The QColormap class maps the
75
color to the hardware.
77
A color can be set by passing an RGB string to setNamedColor() (such
78
as "#112233"), or a color name (such as "blue"). The names are taken
79
from X11's rgb.txt database but can also be used on all platforms. To get
80
a lighter or darker color use light() and dark() respectively.
81
Colors can also be set using setRgb() and setHsv(). The color
82
components can be accessed in one go with rgb() and hsv(), or
83
individually with red(), green(), and blue().
87
Because many people don't know the HSV color model very well, we'll
88
cover it briefly here.
90
The RGB model is hardware-oriented. Its representation is close to
91
what most monitors show. In contrast, HSV represents color in a way
92
more suited to the human perception of color. For example, the
93
relationships "stronger than", "darker than", and "the opposite of"
94
are easily expressed in HSV but are much harder to express in RGB.
96
HSV, like RGB, has three components:
100
\i H, for hue, is in the range 0 to 359 if the color is chromatic (not
101
gray), or meaningless if it is gray. It represents degrees on the
102
color wheel familiar to most people. Red is 0 (degrees), green is
103
120, and blue is 240.
105
\i S, for saturation, is in the range 0 to 255, and the bigger it is,
106
the stronger the color is. Grayish colors have saturation near 0; very
107
strong colors have saturation near 255.
109
\i V, for value, is in the range 0 to 255 and represents lightness or
110
brightness of the color. 0 is black; 255 is as far from black as
115
Here are some examples: pure red is H=0, S=255, V=255; a dark red,
116
moving slightly towards the magenta, could be H=350 (equivalent to
117
-10), S=255, V=180; a grayish light red could have H about 0 (say
118
350-359 or 0-10), S about 50-100, and S=255.
120
Qt returns a hue value of -1 for achromatic colors. If you pass a
121
hue value that is too large, Qt forces it into range. Hue 360 or 720 is
122
treated as 0; hue 540 is treated as 180.
124
\sa QPalette, QApplication::setColorSpec()
128
/*****************************************************************************
129
QColor member functions
130
*****************************************************************************/
135
The type of color specified, either RGB, HSV or CMYK.
144
\fn Spec QColor::spec() const
146
Returns how the color was specified.
153
Constructs an invalid color with the RGB value (0, 0, 0). An
154
invalid color is a color that is not properly set up for the
155
underlying window system.
157
The alpha value of an invalid color is unspecified.
165
Constructs a new color with a color value of \a color.
167
QColor::QColor(Qt::GlobalColor color)
169
#define QRGB(r, g, b) \
170
QRgb(((0xff << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)))
171
#define QRGBA(r, g, b, a) \
172
QRgb(((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff))
174
static const QRgb global_colors[] = {
175
QRGB(255, 255, 255), // Qt::color0
176
QRGB( 0, 0, 0), // Qt::color1
177
QRGB( 0, 0, 0), // black
178
QRGB(255, 255, 255), // white
180
* From the "The Palette Manager: How and Why" by Ron Gery,
181
* March 23, 1992, archived on MSDN:
183
* The Windows system palette is broken up into two
184
* sections, one with fixed colors and one with colors
185
* that can be changed by applications. The system palette
186
* predefines 20 entries; these colors are known as the
187
* static or reserved colors and consist of the 16 colors
188
* found in the Windows version 3.0 VGA driver and 4
189
* additional colors chosen for their visual appeal. The
190
* DEFAULT_PALETTE stock object is, as the name implies,
191
* the default palette selected into a device context (DC)
192
* and consists of these static colors. Applications can
193
* set the remaining 236 colors using the Palette Manager.
195
* The 20 reserved entries have indices in [0,9] and
196
* [246,255]. We reuse 17 of them.
198
QRGB(128, 128, 128), // index 248 medium gray
199
QRGB(160, 160, 164), // index 247 light gray
200
QRGB(192, 192, 192), // index 7 light gray
201
QRGB(255, 0, 0), // index 249 red
202
QRGB( 0, 255, 0), // index 250 green
203
QRGB( 0, 0, 255), // index 252 blue
204
QRGB( 0, 255, 255), // index 254 cyan
205
QRGB(255, 0, 255), // index 253 magenta
206
QRGB(255, 255, 0), // index 251 yellow
207
QRGB(128, 0, 0), // index 1 dark red
208
QRGB( 0, 128, 0), // index 2 dark green
209
QRGB( 0, 0, 128), // index 4 dark blue
210
QRGB( 0, 128, 128), // index 6 dark cyan
211
QRGB(128, 0, 128), // index 5 dark magenta
212
QRGB(128, 128, 0), // index 3 dark yellow
213
QRGBA(0, 0, 0, 0) // transparent
218
setRgb(qRed(global_colors[color]),
219
qGreen(global_colors[color]),
220
qBlue(global_colors[color]),
221
qAlpha(global_colors[color]));
225
\fn QColor::QColor(int r, int g, int b, int a = 255)
227
Constructs a color with the RGB value \a r, \a g, \a b, and the
228
alpha-channel (transparency) value of \a a, in the same way as setRgb().
230
The color is left invalid if any of the arguments are invalid.
236
Constructs a color with the value \a color. The alpha component is
237
ignored and set to solid.
242
QColor::QColor(QRgb color)
245
ct.argb.alpha = 0xffff;
246
ct.argb.red = qRed(color) * 0x101;
247
ct.argb.green = qGreen(color) * 0x101;
248
ct.argb.blue = qBlue(color) * 0x101;
254
\fn QColor::QColor(const QString &name)
256
Constructs a named color in the same way as setNamedColor() using
259
The color is left invalid if the \a name cannot be parsed.
265
\fn QColor::QColor(const char *name)
267
Constructs a named color in the same way as setNamedColor() using
270
The color is left invalid if the \a name cannot be parsed.
276
\fn QColor::QColor(const QColor &color)
278
Constructs a color that is a copy of \a color.
282
\fn bool QColor::isValid() const
284
Returns true if the color is valid; otherwise returns false.
286
If the color was constructed using the default constructor, false is
291
Returns the name of the color in the format "#AARRGGBB"; i.e. a "#"
292
character followed by three two-digit hexadecimal numbers.
297
QString QColor::name() const
299
#ifndef QT_NO_SPRINTF
301
s.sprintf("#%02x%02x%02x", red(), green(), blue());
305
sprintf(s, "#%02x%02x%02x", red(), green(), blue());
311
Sets the RGB value to \a name, which may be in one of these
314
\i #RGB (each of R, G, and B is a single hex digit)
318
\i A name from the X color database (rgb.txt) (e.g.
319
"steelblue" or "gainsboro"). These color names work on all platforms.
322
The color is invalid if \a name cannot be parsed.
325
void QColor::setNamedColor(const QString &name)
327
if (name.isEmpty()) {
332
QByteArray n = name.toLatin1();
333
if (name[0] == '#') {
335
if (qt_get_hex_rgb(n, &rgb)) {
338
qWarning("QColor::setNamedColor: could not parse color '%s'", n.constData());
345
if (qt_get_named_rgb(n, &rgb)) {
348
qWarning("QColor::setNamedColor: unknown color name '%s'", n.constData());
354
Returns a QStringList containing the color names Qt knows about.
356
QStringList QColor::colorNames()
358
return qt_get_colornames();
364
Returns the current RGB value as HSV. The contents of the \a h, \a
365
s, and \a v pointers are set to the HSV values, and the contents
366
of \a a is set to the alpha-channel (transparency) value. If any
367
of the pointers are null, the function does nothing.
371
void QColor::getHsvF(qreal *h, qreal *s, qreal *v, qreal *a) const
376
if (cspec != Invalid && cspec != Hsv) {
377
toHsv().getHsvF(h, s, v, a);
381
*h = ct.ahsv.hue == USHRT_MAX ? -1.0 : ct.ahsv.hue / 36000.0;
382
*s = ct.ahsv.saturation / qreal(USHRT_MAX);
383
*v = ct.ahsv.value / qreal(USHRT_MAX);
386
*a = ct.ahsv.alpha / qreal(USHRT_MAX);
390
Returns the current RGB value as HSV. The contents of the \a h, \a
391
s, and \a v pointers are set to the HSV values, and the contents
392
of \a a is set to the alpha-channel (transparency) value. If any
393
of the pointers are null, the function does nothing.
395
The hue (which \a h points to) is set to -1 if the color is
398
\warning Colors are stored internally as RGB values, so getHSv()
399
may return slightly different values to those set by setHsv().
403
void QColor::getHsv(int *h, int *s, int *v, int *a) const
408
if (cspec != Invalid && cspec != Hsv) {
409
toHsv().getHsv(h, s, v, a);
413
*h = ct.ahsv.hue == USHRT_MAX ? -1 : ct.ahsv.hue / 100;
414
*s = ct.ahsv.saturation >> 8;
415
*v = ct.ahsv.value >> 8;
418
*a = ct.ahsv.alpha >> 8;
424
The value of \a h, \a s, \a v, and \a a must all be in the range 0.0-1.0.
426
void QColor::setHsvF(qreal h, qreal s, qreal v, qreal a)
428
if (((h < 0.0 || h > 1.0) && h != -1.0)
429
|| (s < 0.0 || s > 1.0)
430
|| (v < 0.0 || v > 1.0)
431
|| (a < 0.0 || a > 1.0)) {
432
qWarning("QColor::setHsv: HSV parameters out of range");
437
ct.ahsv.alpha = qRound(a * USHRT_MAX);
438
ct.ahsv.hue = h == -1.0 ? USHRT_MAX : qRound(h * 36000);
439
ct.ahsv.saturation = qRound(s * USHRT_MAX);
440
ct.ahsv.value = qRound(v * USHRT_MAX);
445
Sets a HSV color value; \a h is the hue, \a s is the saturation,
446
\a v is the value and \a a is the alpha component of the HSV
449
If \a s, \a v or \a a are not in the range 0 to 255, or \a h is <
450
-1, the color is not changed.
452
\sa getHsv(), setRgb()
454
void QColor::setHsv(int h, int s, int v, int a)
456
if (h < -1 || (uint)s > 255 || (uint)v > 255 || (uint)a > 255) {
457
qWarning("QColor::setHsv: HSV parameters out of range");
463
ct.ahsv.alpha = a * 0x101;
464
ct.ahsv.hue = h == -1 ? USHRT_MAX : (h % 360) * 100;
465
ct.ahsv.saturation = s * 0x101;
466
ct.ahsv.value = v * 0x101;
473
Sets the contents pointed to by \a r, \a g, \a b, and \a a, to the
474
red, green, blue, and alpha-channel (transparency) components of
477
\sa rgb(), setRgb(), getHsv()
479
void QColor::getRgbF(qreal *r, qreal *g, qreal *b, qreal *a) const
484
if (cspec != Invalid && cspec != Rgb) {
485
toRgb().getRgbF(r, g, b, a);
489
*r = ct.argb.red / qreal(USHRT_MAX);
490
*g = ct.argb.green / qreal(USHRT_MAX);
491
*b = ct.argb.blue / qreal(USHRT_MAX);
494
*a = ct.argb.alpha / qreal(USHRT_MAX);
499
Sets the contents pointed to by \a r, \a g, \a b, and \a a, to the
500
red, green, blue, and alpha-channel (transparency) components of
503
\sa rgb(), setRgb(), getHsv()
505
void QColor::getRgb(int *r, int *g, int *b, int *a) const
510
if (cspec != Invalid && cspec != Rgb) {
511
toRgb().getRgb(r, g, b, a);
515
*r = ct.argb.red >> 8;
516
*g = ct.argb.green >> 8;
517
*b = ct.argb.blue >> 8;
520
*a = ct.argb.alpha >> 8;
524
\fn void QColor::getRgba(int *r, int *g, int *b, int *a) const
526
Populates \a r, \a g, and \a b with the color's RGB values.
527
\a a is populated with the color's alpha channel (opacity) value.
528
All the values are in the range 0 to 255.
530
\sa setRgba() setRgb() setHsv()
534
\fn void QColor::setRgbF(qreal r, qreal g, qreal b, qreal a)
536
Sets the color channels of this color to \a r (red), \a g (green),
537
\a b (blue) and \a a (alpha, transparency).
541
All values must be in the range 0.0-1.0.
543
void QColor::setRgbF(qreal r, qreal g, qreal b, qreal a)
545
if (r < 0.0 || r > 1.0
546
|| g < 0.0 || g > 1.0
547
|| b < 0.0 || b > 1.0
548
|| a < 0.0 || a > 1.0) {
549
qWarning("QColor::setRgb: RGB parameter(s) out of range");
555
ct.argb.alpha = qRound(a * USHRT_MAX);
556
ct.argb.red = qRound(r * USHRT_MAX);
557
ct.argb.green = qRound(g * USHRT_MAX);
558
ct.argb.blue = qRound(b * USHRT_MAX);
563
Sets the RGB value to \a r, \a g, \a b and the alpha value to \a
564
a. The arguments, \a r, \a g, \a b and \a a must all be in the
565
range 0 to 255. The color becomes invalid if any of them are
566
outside the legal range.
570
void QColor::setRgb(int r, int g, int b, int a)
572
if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255 || (uint)a > 255) {
573
qWarning("QColor::setRgb: RGB parameter(s) out of range");
579
ct.argb.alpha = a * 0x101;
580
ct.argb.red = r * 0x101;
581
ct.argb.green = g * 0x101;
582
ct.argb.blue = b * 0x101;
587
\fn void QColor::setRgba(int r, int g, int b, int a)
589
Sets the RGBA value to \a r, \a g, \a b, \a a. The arguments, \a
590
r, \a g, \a b, and \a a must all be in the range 0 to 255. If any of
591
them are outside the legal range, the color is not changed.
593
\sa getRgba(), setRgb(), setHsv()
597
\fn QRgb QColor::rgba() const
599
Returns the RGB value of the color. Note that unlike rgb(), the
600
alpha is not stripped.
602
The return type \e QRgb is equivalent to \c unsigned \c int.
604
For an invalid color, the alpha value of the returned color is
607
\sa setRgb(), setRgba(), getHsv(), qRed(), qBlue(), qGreen(), isValid()
610
QRgb QColor::rgba() const
612
if (cspec != Invalid && cspec != Rgb)
613
return toRgb().rgba();
614
return qRgba(ct.argb.red >> 8, ct.argb.green >> 8, ct.argb.blue >> 8, ct.argb.alpha >> 8);
618
Sets the RGBA value to \a rgba. Note that unlike setRgb(QRgb rgb),
619
this function does not ignore the alpha.
621
The type \e QRgb is equivalent to \c unsigned \c int.
625
void QColor::setRgba(QRgb rgba)
628
ct.argb.alpha = qAlpha(rgba) * 0x101;
629
ct.argb.red = qRed(rgba) * 0x101;
630
ct.argb.green = qGreen(rgba) * 0x101;
631
ct.argb.blue = qBlue(rgba) * 0x101;
636
\fn QRgb QColor::rgb() const
638
Returns the RGB value of the color. The alpha is stripped for compatibility.
640
The return type \e QRgb is equivalent to \c unsigned \c int.
642
For an invalid color, the alpha value of the returned color is
645
\sa setRgb(), getHsv(), qRed(), qBlue(), qGreen(), isValid()
647
QRgb QColor::rgb() const
649
if (cspec != Invalid && cspec != Rgb)
650
return toRgb().rgb();
651
return qRgb(ct.argb.red >> 8, ct.argb.green >> 8, ct.argb.blue >> 8);
656
Sets the RGB value to \a rgb, ignoring the alpha.
658
The type \e QRgb is equivalent to \c unsigned \c int.
662
void QColor::setRgb(QRgb rgb)
665
ct.argb.alpha = 0xffff;
666
ct.argb.red = qRed(rgb) * 0x101;
667
ct.argb.green = qGreen(rgb) * 0x101;
668
ct.argb.blue = qBlue(rgb) * 0x101;
673
Returns the alpha color component of this color.
675
\sa alphaF() red() green() blue()
677
int QColor::alpha() const
678
{ return ct.argb.alpha >> 8; }
682
Sets the alpha of this color to \a alpha. Integer alpha is
683
specified in the range 0-255.
687
void QColor::setAlpha(int alpha)
689
ct.argb.alpha = alpha * 0x101;
693
Returns the alpha color component of this color.
695
\sa alpha() redF() greenF() blueF()
697
qreal QColor::alphaF() const
698
{ return ct.argb.alpha / qreal(USHRT_MAX); }
701
Sets the alpha of this color to \a alpha. Qreal alpha is
702
specified in the range 0-1.
704
void QColor::setAlphaF(qreal alpha)
706
qreal tmp = alpha * USHRT_MAX;
707
ct.argb.alpha = qRound(tmp);
712
Returns the red color component of this color.
714
\sa redF() green() blue() alpha()
716
int QColor::red() const
718
if (cspec != Invalid && cspec != Rgb)
719
return toRgb().red();
720
return ct.argb.red >> 8;
724
Sets the red color component of this color to \a red. Int
725
components are specified in the range 0-255.
727
void QColor::setRed(int red)
729
ct.argb.red = red * 0x101;
733
Returns the green color component of this color.
735
\sa greenF() red() blue() alpha()
737
int QColor::green() const
739
if (cspec != Invalid && cspec != Rgb)
740
return toRgb().green();
741
return ct.argb.green >> 8;
745
Sets the green color component of this color to \a green. Int
746
components are specified in the range 0-255.
748
void QColor::setGreen(int green)
750
ct.argb.green = green * 0x101;
755
Returns the blue color component of this color.
757
\sa blueF() red() green() alpha()
759
int QColor::blue() const
761
if (cspec != Invalid && cspec != Rgb)
762
return toRgb().blue();
763
return ct.argb.blue >> 8;
768
Sets the blue color component of this color to \a blue. Int
769
components are specified in the range 0-255.
771
void QColor::setBlue(int blue)
773
ct.argb.blue = blue * 0x101;
777
Returns the red color component of this color.
779
\sa red() greenF() blueF() alphaF()
781
qreal QColor::redF() const
783
if (cspec != Invalid && cspec != Rgb)
784
return toRgb().redF();
785
return ct.argb.red / qreal(USHRT_MAX);
790
Sets the red color component of this color to \a red. Float
791
components are specified in the range 0-1.
793
void QColor::setRedF(qreal red)
795
ct.argb.red = qRound(red * USHRT_MAX);
799
Returns the green color component of this color.
801
\sa green() redF() blueF() alphaF()
803
qreal QColor::greenF() const
805
if (cspec != Invalid && cspec != Rgb)
806
return toRgb().greenF();
807
return ct.argb.green / qreal(USHRT_MAX);
812
Sets the green color component of this color to \a green. Float
813
components are specified in the range 0-1.
815
void QColor::setGreenF(qreal green)
817
ct.argb.green = qRound(green * USHRT_MAX);
821
Returns the blue color component of this color.
823
\sa blue() redF() greenF() alphaF()
825
qreal QColor::blueF() const
827
if (cspec != Invalid && cspec != Rgb)
828
return toRgb().blueF();
829
return ct.argb.blue / qreal(USHRT_MAX);
833
Sets the blue color component of this color to \a blue. Float
834
components are specified in the range 0-1.
836
void QColor::setBlueF(qreal blue)
838
ct.argb.blue = qRound(blue * USHRT_MAX);
842
Returns the hue color component of this color.
844
\sa hueF() saturation() value() alpha()
846
int QColor::hue() const
848
if (cspec != Invalid && cspec != Hsv)
849
return toHsv().hue();
850
return ct.ahsv.hue == USHRT_MAX ? -1 : ct.ahsv.hue / 100;
854
Returns the saturation color component of this color.
856
\sa saturationF() hue() value() alpha()
858
int QColor::saturation() const
860
if (cspec != Invalid && cspec != Hsv)
861
return toHsv().saturation();
862
return ct.ahsv.saturation >> 8;
866
Returns the value color component of this color.
868
\sa valueF() hue() saturation() alpha()
870
int QColor::value() const
872
if (cspec != Invalid && cspec != Hsv)
873
return toHsv().value();
874
return ct.ahsv.value >> 8;
878
Returns the hue color component of this color.
880
\sa hue() saturationF() valueF() alphaF()
882
qreal QColor::hueF() const
884
if (cspec != Invalid && cspec != Hsv)
885
return toHsv().hueF();
886
return ct.ahsv.hue == USHRT_MAX ? -1.0 : ct.ahsv.hue / 36000.0;
890
Returns the saturation color component of this color.
892
\sa saturation() hueF() valueF() alphaF()
894
qreal QColor::saturationF() const
896
if (cspec != Invalid && cspec != Hsv)
897
return toHsv().saturationF();
898
return ct.ahsv.saturation / qreal(USHRT_MAX);
902
Returns the value color component of this color.
904
\sa value() hueF() saturationF() alphaF()
906
qreal QColor::valueF() const
908
if (cspec != Invalid && cspec != Hsv)
909
return toHsv().valueF();
910
return ct.ahsv.value / qreal(USHRT_MAX);
914
Returns the cyan color component of this color.
916
\sa cyanF() black() magenta() yellow() alpha()
918
int QColor::cyan() const
920
if (cspec != Invalid && cspec != Cmyk)
921
return toCmyk().cyan();
922
return ct.acmyk.cyan >> 8;
926
Returns the magenta color component of this color.
928
\sa magentaF() cyan() black() yellow() alpha()
930
int QColor::magenta() const
932
if (cspec != Invalid && cspec != Cmyk)
933
return toCmyk().magenta();
934
return ct.acmyk.magenta >> 8;
938
Returns the yellow color component of this color.
940
\sa yellowF() cyan() magenta() black() alpha()
942
int QColor::yellow() const
944
if (cspec != Invalid && cspec != Cmyk)
945
return toCmyk().yellow();
946
return ct.acmyk.yellow >> 8;
950
Returns the black color component of this color.
952
\sa blackF() cyan() magenta() yellow() alpha()
954
int QColor::black() const
956
if (cspec != Invalid && cspec != Cmyk)
957
return toCmyk().black();
958
return ct.acmyk.black >> 8;
962
Returns the cyan color component of this color.
964
\sa cyan() blackF() magentaF() yellowF() alphaF()
966
qreal QColor::cyanF() const
968
if (cspec != Invalid && cspec != Cmyk)
969
return toCmyk().cyanF();
970
return ct.acmyk.cyan / qreal(USHRT_MAX);
974
Returns the magenta color component of this color.
976
\sa magenta() cyanF() blackF() yellowF() alphaF()
978
qreal QColor::magentaF() const
980
if (cspec != Invalid && cspec != Cmyk)
981
return toCmyk().magentaF();
982
return ct.acmyk.magenta / qreal(USHRT_MAX);
986
Returns the yellow color component of this color.
988
\sa yellow() cyanF() magentaF() blackF() alphaF()
990
qreal QColor::yellowF() const
992
if (cspec != Invalid && cspec != Cmyk)
993
return toCmyk().yellowF();
994
return ct.acmyk.yellow / qreal(USHRT_MAX);
998
Returns the black color component of this color.
1000
\sa black() cyanF() magentaF() yellowF() alphaF()
1002
qreal QColor::blackF() const
1004
if (cspec != Invalid && cspec != Cmyk)
1005
return toCmyk().blackF();
1006
return ct.acmyk.black / qreal(USHRT_MAX);
1010
Returns an RGB QColor based on this color.
1012
\sa fromRgb() toCmyk() toHsv()
1014
QColor QColor::toRgb() const
1016
if (!isValid() || cspec == Rgb)
1021
color.ct.argb.alpha = ct.argb.alpha;
1022
color.ct.argb.pad = 0;
1027
if (ct.ahsv.saturation == 0 || ct.ahsv.hue == USHRT_MAX) {
1029
color.ct.argb.red = color.ct.argb.green = color.ct.argb.blue = ct.ahsv.value;
1034
const qreal h = ct.ahsv.hue / 6000.;
1035
const qreal s = ct.ahsv.saturation / qreal(USHRT_MAX);
1036
const qreal v = ct.ahsv.value / qreal(USHRT_MAX);
1037
const int i = int(h);
1038
const qreal f = h - i;
1039
const qreal p = v * (1.0 - s);
1042
const qreal q = v * (1.0 - (s * f));
1046
color.ct.argb.red = qRound(q * USHRT_MAX);
1047
color.ct.argb.green = qRound(v * USHRT_MAX);
1048
color.ct.argb.blue = qRound(p * USHRT_MAX);
1051
color.ct.argb.red = qRound(p * USHRT_MAX);
1052
color.ct.argb.green = qRound(q * USHRT_MAX);
1053
color.ct.argb.blue = qRound(v * USHRT_MAX);
1056
color.ct.argb.red = qRound(v * USHRT_MAX);
1057
color.ct.argb.green = qRound(p * USHRT_MAX);
1058
color.ct.argb.blue = qRound(q * USHRT_MAX);
1062
const qreal t = v * (1.0 - (s * (1.0 - f)));
1066
color.ct.argb.red = qRound(v * USHRT_MAX);
1067
color.ct.argb.green = qRound(t * USHRT_MAX);
1068
color.ct.argb.blue = qRound(p * USHRT_MAX);
1071
color.ct.argb.red = qRound(p * USHRT_MAX);
1072
color.ct.argb.green = qRound(v * USHRT_MAX);
1073
color.ct.argb.blue = qRound(t * USHRT_MAX);
1076
color.ct.argb.red = qRound(t * USHRT_MAX);
1077
color.ct.argb.green = qRound(p * USHRT_MAX);
1078
color.ct.argb.blue = qRound(v * USHRT_MAX);
1086
const qreal c = ct.acmyk.cyan / qreal(USHRT_MAX);
1087
const qreal m = ct.acmyk.magenta / qreal(USHRT_MAX);
1088
const qreal y = ct.acmyk.yellow / qreal(USHRT_MAX);
1089
const qreal k = ct.acmyk.black / qreal(USHRT_MAX);
1091
color.ct.argb.red = qRound((1.0 - (c * (1.0 - k) + k)) * USHRT_MAX);
1092
color.ct.argb.green = qRound((1.0 - (m * (1.0 - k) + k)) * USHRT_MAX);
1093
color.ct.argb.blue = qRound((1.0 - (y * (1.0 - k) + k)) * USHRT_MAX);
1104
#define Q_MAX_3(a, b, c) ( ( a > b && a > c) ? a : (b > c ? b : c) )
1105
#define Q_MIN_3(a, b, c) ( ( a < b && a < c) ? a : (b < c ? b : c) )
1109
Returns an HSV QColor based on this color.
1111
\sa fromHsv() toCmyk() toRgb()
1113
QColor QColor::toHsv() const
1119
return toRgb().toHsv();
1123
color.ct.ahsv.alpha = ct.argb.alpha;
1124
color.ct.ahsv.pad = 0;
1126
const qreal r = ct.argb.red / qreal(USHRT_MAX);
1127
const qreal g = ct.argb.green / qreal(USHRT_MAX);
1128
const qreal b = ct.argb.blue / qreal(USHRT_MAX);
1129
const qreal max = Q_MAX_3(r, g, b);
1130
const qreal min = Q_MIN_3(r, g, b);
1131
const qreal delta = max - min;
1132
color.ct.ahsv.value = qRound(max * USHRT_MAX);
1134
// achromatic case, hue is undefined
1135
color.ct.ahsv.hue = USHRT_MAX;
1136
color.ct.ahsv.saturation = 0;
1140
color.ct.ahsv.saturation = qRound((delta / max) * USHRT_MAX);
1142
hue = ((g - b) /delta);
1143
} else if (g == max) {
1144
hue = (2.0 + (b - r) / delta);
1145
} else if (b == max) {
1146
hue = (4.0 + (r - g) / delta);
1148
Q_ASSERT_X(false, "QColor::toHsv", "internal error");
1153
color.ct.ahsv.hue = qRound(hue * 100);
1160
Returns a CMYK QColor based on this color.
1162
\sa fromCmyk() toHsv() toRgb()
1164
QColor QColor::toCmyk() const
1169
return toRgb().toCmyk();
1173
color.ct.acmyk.alpha = ct.argb.alpha;
1176
const qreal r = ct.argb.red / qreal(USHRT_MAX);
1177
const qreal g = ct.argb.green / qreal(USHRT_MAX);
1178
const qreal b = ct.argb.blue / qreal(USHRT_MAX);
1184
const qreal k = qMin(c, qMin(m, y));
1185
c = (c - k) / (1.0 - k);
1186
m = (m - k) / (1.0 - k);
1187
y = (y - k) / (1.0 - k);
1189
color.ct.acmyk.cyan = qRound(c * USHRT_MAX);
1190
color.ct.acmyk.magenta = qRound(m * USHRT_MAX);
1191
color.ct.acmyk.yellow = qRound(y * USHRT_MAX);
1192
color.ct.acmyk.black = qRound(k * USHRT_MAX);
1198
Returns a new QColor of the given color specification based on
1201
QColor QColor::convertTo(QColor::Spec colorSpec) const
1203
if (colorSpec == cspec)
1205
switch (colorSpec) {
1215
return QColor(); // must be invalid
1220
Creates a color from the argb value \a rgb.
1222
The alpha component of \a rgb is ignored. For conversion from an RGBA value
1228
QColor QColor::fromRgb(QRgb rgb)
1230
return fromRgb(qRed(rgb), qGreen(rgb), qBlue(rgb));
1235
Creates a color from the rgba value \a rgba.
1240
QColor QColor::fromRgba(QRgb rgba)
1242
return fromRgb(qRed(rgba), qGreen(rgba), qBlue(rgba), qAlpha(rgba));
1246
Static convenience function that returns a QColor constructed from
1247
the RGB color values, \a r (red), \a g (green), \a b (blue),
1248
and \a a (alpha-channel, i.e. transparency).
1250
All the values must be in the range 0-255.
1252
\sa toRgb() fromCmyk() fromHsv()
1254
QColor QColor::fromRgb(int r, int g, int b, int a)
1256
if (r < 0 || r > 255
1259
|| a < 0 || a > 255) {
1260
qWarning("QColor::fromRgb: RGB paramaters out of range");
1266
color.ct.argb.alpha = a * 0x101;
1267
color.ct.argb.red = r * 0x101;
1268
color.ct.argb.green = g * 0x101;
1269
color.ct.argb.blue = b * 0x101;
1270
color.ct.argb.pad = 0;
1277
Static convenience function that returns a QColor constructed from
1278
the RGB color values, \a r (red), \a g (green), \a b (blue),
1279
and \a a (alpha-channel, i.e. transparency).
1281
All the values must be in the range 0.0-1.0.
1283
\sa toRgb() fromCmyk() fromHsv()
1285
QColor QColor::fromRgbF(qreal r, qreal g, qreal b, qreal a)
1287
if (r < 0.0 || r > 1.0
1288
|| g < 0.0 || g > 1.0
1289
|| b < 0.0 || b > 1.0
1290
|| a < 0.0 || a > 1.0) {
1291
qWarning("QColor::fromRgb: RGB paramaters out of range");
1297
color.ct.argb.alpha = qRound(a * USHRT_MAX);
1298
color.ct.argb.red = qRound(r * USHRT_MAX);
1299
color.ct.argb.green = qRound(g * USHRT_MAX);
1300
color.ct.argb.blue = qRound(b * USHRT_MAX);
1301
color.ct.argb.pad = 0;
1306
Static convenience function that returns a QColor constructed from
1307
the HSV color values, \a h (hue), \a s (saturation), \a v (value),
1308
and \a a (alpha-channel, i.e. transparency).
1310
The value of \a s, \a v, and \a a must all be in the range
1311
0-255; the value of \a h must be in the range 0-360.
1313
\sa toHsv() fromCmyk() fromRgb()
1315
QColor QColor::fromHsv(int h, int s, int v, int a)
1317
if (((h < 0 || h >= 360) && h != -1)
1320
|| a < 0 || a > 255) {
1321
qWarning("QColor::fromHsv: HSV parameters out of range");
1327
color.ct.ahsv.alpha = a * 0x101;
1328
color.ct.ahsv.hue = h == -1 ? USHRT_MAX : (h % 360) * 100;
1329
color.ct.ahsv.saturation = s * 0x101;
1330
color.ct.ahsv.value = v * 0x101;
1331
color.ct.ahsv.pad = 0;
1338
Static convenience function that returns a QColor constructed from
1339
the HSV color values, \a h (hue), \a s (saturation), \a v (value),
1340
and \a a (alpha-channel, i.e. transparency).
1342
The value of \a h, \a s and \a v must all be in the range 0.0-1.0.
1344
\sa toHsv() fromCmyk() fromRgb()
1346
QColor QColor::fromHsvF(qreal h, qreal s, qreal v, qreal a)
1348
if (((h < 0.0 || h > 1.0) && h != -1.0)
1349
|| (s < 0.0 || s > 1.0)
1350
|| (v < 0.0 || v > 1.0)
1351
|| (a < 0.0 || a > 1.0)) {
1352
qWarning("QColor::fromHsv: HSV parameters out of range");
1358
color.ct.ahsv.alpha = qRound(a * USHRT_MAX);
1359
color.ct.ahsv.hue = h == -1.0 ? USHRT_MAX : qRound(h * 36000);
1360
color.ct.ahsv.saturation = qRound(s * USHRT_MAX);
1361
color.ct.ahsv.value = qRound(v * USHRT_MAX);
1362
color.ct.ahsv.pad = 0;
1367
Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a,
1368
to the cyan, magenta, yellow, black, and alpha-channel
1369
(transparency) components of the CMYK value.
1371
\sa setCmyk() getRgb() getHsv()
1373
void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a)
1375
if (!c || !m || !y || !k)
1378
if (cspec != Invalid && cspec != Cmyk) {
1379
toCmyk().getCmyk(c, m, y, k, a);
1383
*c = ct.acmyk.cyan >> 8;
1384
*m = ct.acmyk.magenta >> 8;
1385
*y = ct.acmyk.yellow >> 8;
1386
*k = ct.acmyk.black >> 8;
1389
*a = ct.acmyk.alpha >> 8;
1395
Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a,
1396
to the cyan, magenta, yellow, black, and alpha-channel
1397
(transparency) components of the CMYK value.
1399
\sa setCmyk() getRgb() getHsv()
1401
void QColor::getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a)
1403
if (!c || !m || !y || !k)
1406
if (cspec != Invalid && cspec != Cmyk) {
1407
toCmyk().getCmykF(c, m, y, k, a);
1411
*c = ct.acmyk.cyan / qreal(USHRT_MAX);
1412
*m = ct.acmyk.magenta / qreal(USHRT_MAX);
1413
*y = ct.acmyk.yellow / qreal(USHRT_MAX);
1414
*k = ct.acmyk.black / qreal(USHRT_MAX);
1417
*a = ct.acmyk.alpha / qreal(USHRT_MAX);
1421
Sets the color to CMYK values, \a c (cyan), \a m (magenta), \a y (yellow),
1422
\a k (black), and \a a (alpha-channel, i.e. transparency).
1424
All the values must be in the range 0-255.
1426
\sa getCmyk() setRgb() setHsv()
1428
void QColor::setCmyk(int c, int m, int y, int k, int a)
1430
if (c < 0 || c > 255
1434
|| a < 0 || a > 255) {
1435
qWarning("QColor::setCmyk: CMYK paramaters out of range");
1440
ct.acmyk.alpha = a * 0x101;
1441
ct.acmyk.cyan = c * 0x101;
1442
ct.acmyk.magenta = m * 0x101;
1443
ct.acmyk.yellow = y * 0x101;
1444
ct.acmyk.black = k * 0x101;
1450
Sets the color to CMYK values, \a c (cyan), \a m (magenta), \a y (yellow),
1451
\a k (black), and \a a (alpha-channel, i.e. transparency).
1453
All the values must be in the range 0.0-1.0.
1455
\sa getCmyk() setRgb() setHsv()
1457
void QColor::setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a)
1459
if (c < 0.0 || c > 1.0
1460
|| m < 0.0 || m > 1.0
1461
|| y < 0.0 || y > 1.0
1462
|| k < 0.0 || k > 1.0
1463
|| a < 0.0 || a > 1.0) {
1464
qWarning("QColor::setCmyk: CMYK paramaters out of range");
1469
ct.acmyk.alpha = qRound(a * USHRT_MAX);
1470
ct.acmyk.cyan = qRound(c * USHRT_MAX);
1471
ct.acmyk.magenta = qRound(m * USHRT_MAX);
1472
ct.acmyk.yellow = qRound(y * USHRT_MAX);
1473
ct.acmyk.black = qRound(k * USHRT_MAX);
1477
Static convenience function that returns a QColor constructed from
1478
the CMYK color values, \a c (cyan), \a m (magenta), \a y (yellow),
1479
\a k (black), and \a a (alpha-channel, i.e. transparency).
1481
All the values must be in the range 0-255.
1483
\sa toCmyk() fromHsv() fromRgb()
1485
QColor QColor::fromCmyk(int c, int m, int y, int k, int a)
1487
if (c < 0 || c > 255
1491
|| a < 0 || a > 255) {
1492
qWarning("QColor::fromCmyk: CMYK paramaters out of range");
1498
color.ct.acmyk.alpha = a * 0x101;
1499
color.ct.acmyk.cyan = c * 0x101;
1500
color.ct.acmyk.magenta = m * 0x101;
1501
color.ct.acmyk.yellow = y * 0x101;
1502
color.ct.acmyk.black = k * 0x101;
1509
Static convenience function that returns a QColor constructed from
1510
the CMYK color values, \a c (cyan), \a m (magenta), \a y (yellow),
1511
\a k (black), and \a a (alpha-channel, i.e. transparency).
1513
All the values must be in the range 0.0-1.0.
1515
\sa toCmyk() fromHsv() fromRgb()
1517
QColor QColor::fromCmykF(qreal c, qreal m, qreal y, qreal k, qreal a)
1519
if (c < 0.0 || c > 1.0
1520
|| m < 0.0 || m > 1.0
1521
|| y < 0.0 || y > 1.0
1522
|| k < 0.0 || k > 1.0
1523
|| a < 0.0 || a > 1.0) {
1524
qWarning("QColor::fromCmyk: CMYK paramaters out of range");
1530
color.ct.acmyk.alpha = qRound(a * USHRT_MAX);
1531
color.ct.acmyk.cyan = qRound(c * USHRT_MAX);
1532
color.ct.acmyk.magenta = qRound(m * USHRT_MAX);
1533
color.ct.acmyk.yellow = qRound(y * USHRT_MAX);
1534
color.ct.acmyk.black = qRound(k * USHRT_MAX);
1539
Returns a lighter (or darker) color, but does not change this
1542
Returns a lighter color if \a factor is greater than 100. Setting
1543
\a factor to 150 returns a color that is 50% brighter.
1545
Returns a darker color if \a factor is less than 100. We recommend
1546
using dark() for this purpose. If \a factor is 0 or negative, the
1547
return value is unspecified.
1549
(This function converts the current RGB color to HSV, multiplies V
1550
by \a factor, and converts the result back to RGB.)
1554
QColor QColor::light(int factor) const
1556
if (factor <= 0) // invalid lightness factor
1558
else if (factor < 100) // makes color darker
1559
return dark(10000/factor);
1561
QColor hsv = toHsv();
1562
int s = hsv.ct.ahsv.saturation;
1563
int v = hsv.ct.ahsv.value;
1566
if (v > USHRT_MAX) {
1567
// overflow... adjust saturation
1574
hsv.ct.ahsv.saturation = s;
1575
hsv.ct.ahsv.value = v;
1577
// convert back to same color spec as original color
1578
return hsv.convertTo(cspec);
1582
Returns a darker (or lighter) color, but does not change this
1585
Returns a darker color if \a factor is greater than 100. Setting
1586
\a factor to 300 returns a color that has one-third the
1589
Returns a lighter color if \a factor is less than 100. We
1590
recommend using light() for this purpose. If \a factor is 0 or
1591
negative, the return value is unspecified.
1593
(This function converts the current RGB color to HSV, divides V by
1594
\a factor and converts back to RGB.)
1598
QColor QColor::dark(int factor) const
1600
if (factor <= 0) // invalid darkness factor
1602
else if (factor < 100) // makes color lighter
1603
return light(10000/factor);
1605
QColor hsv = toHsv();
1606
hsv.ct.ahsv.value = (hsv.ct.ahsv.value * 100) / factor;
1608
// convert back to same color spec as original color
1609
return hsv.convertTo(cspec);
1613
Assigns a copy of the color \a color to this color, and returns a
1616
QColor &QColor::operator=(const QColor &color)
1618
cspec = color.cspec;
1619
ct.argb = color.ct.argb;
1624
Assigns a copy of the \a color and returns a reference to this color.
1626
QColor &QColor::operator=(Qt::GlobalColor color)
1628
return operator=(QColor(color));
1632
Returns true if this color has the same RGB value as the color \a
1633
color; otherwise returns false.
1635
bool QColor::operator==(const QColor &color) const
1637
return (cspec == color.cspec
1638
&& ct.argb.alpha == color.ct.argb.alpha
1639
&& ct.argb.red == color.ct.argb.red
1640
&& ct.argb.green == color.ct.argb.green
1641
&& ct.argb.blue == color.ct.argb.blue
1642
&& ct.argb.pad == color.ct.argb.pad);
1646
Returns true if this color has a different RGB value from the
1647
color \a color; otherwise returns false.
1649
bool QColor::operator!=(const QColor &color) const
1650
{ return !operator==(color); }
1654
Returns the color as a QVariant
1656
QColor::operator QVariant() const
1658
return QVariant(QVariant::Color, this);
1663
Marks the color as invalid and sets all components to zero (alpha
1664
is set to fully opaque for compatibility with Qt 3).
1666
void QColor::invalidate()
1669
ct.argb.alpha = USHRT_MAX;
1679
Returns the pixel value.
1681
This value is used by the underlying window system to refer to a
1682
color. It can be thought of as an index into the display
1683
hardware's color table, but the value is an arbitrary 32-bit
1686
The \a screen parameter is only used under X11 to specify the X11
1689
uint QColor::pixel(int screen) const
1691
QColormap cmap = QColormap::instance(screen);
1692
return cmap.pixel(*this);
1695
#endif // QT3_SUPPORT
1697
/*****************************************************************************
1698
QColor stream functions
1699
*****************************************************************************/
1701
#ifndef QT_NO_DEBUG_STREAM
1702
QDebug operator<<(QDebug dbg, const QColor &c)
1704
#ifndef Q_BROKEN_DEBUG_STREAM
1706
dbg.nospace() << "QColor(Invalid)";
1707
else if (c.spec() == QColor::Rgb)
1708
dbg.nospace() << "QColor(ARGB " << c.alphaF() << ", " << c.redF() << ", " << c.greenF() << ", " << c.blueF() << ")";
1709
else if (c.spec() == QColor::Hsv)
1710
dbg.nospace() << "QColor(AHSV " << c.alphaF() << ", " << c.hueF() << ", " << c.saturationF() << ", " << c.valueF() << ")";
1711
else if (c.spec() == QColor::Cmyk)
1712
dbg.nospace() << "QColor(ACMYK " << c.alphaF() << ", " << c.cyanF() << ", " << c.magentaF() << ", " << c.yellowF() << ", "
1713
<< c.blackF()<< ")";
1717
qWarning("This compiler doesn't support streaming QColor to QDebug");
1724
#ifndef QT_NO_DATASTREAM
1726
\fn QDataStream &operator<<(QDataStream &stream, const QColor &color)
1729
Writes the \a color to the \a stream.
1731
\sa \link datastreamformat.html Format of the QDataStream operators \endlink
1733
QDataStream &operator<<(QDataStream &stream, const QColor &color)
1735
if (stream.version() < 7) {
1736
quint32 p = (quint32)color.rgb();
1737
if (stream.version() == 1) // Swap red and blue
1738
p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
1742
qint8 s = color.cspec;
1743
quint16 a = color.ct.argb.alpha;
1744
quint16 r = color.ct.argb.red;
1745
quint16 g = color.ct.argb.green;
1746
quint16 b = color.ct.argb.blue;
1747
quint16 p = color.ct.argb.pad;
1760
\fn QDataStream &operator>>(QDataStream &stream, QColor &color)
1763
Reads the \a color from the \a stream.
1765
\sa \link datastreamformat.html Format of the QDataStream operators \endlink
1767
QDataStream &operator>>(QDataStream &stream, QColor &color)
1769
if (stream.version() < 7) {
1772
if (stream.version() == 1) // Swap red and blue
1773
p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
1779
quint16 a, r, g, b, p;
1787
color.cspec = QColor::Spec(s);
1788
color.ct.argb.alpha = a;
1789
color.ct.argb.red = r;
1790
color.ct.argb.green = g;
1791
color.ct.argb.blue = b;
1792
color.ct.argb.pad = p;
1801
/*****************************************************************************
1802
QColor global functions (documentation only)
1803
*****************************************************************************/
1806
\fn int qRed(QRgb rgb)
1809
Returns the red component of the RGBA quadruplet \a rgb.
1810
\sa qRgb(), QColor::red()
1814
\fn int qGreen(QRgb rgb)
1817
Returns the green component of the RGBA quadruplet \a rgb.
1818
\sa qRgb(), QColor::green()
1822
\fn int qBlue(QRgb rgb)
1825
Returns the blue component of the RGBA quadruplet \a rgb.
1826
\sa qRgb(), QColor::blue()
1830
\fn int qAlpha(QRgb rgba)
1833
Returns the alpha component of the RGBA quadruplet \a rgba.
1837
\fn QRgb qRgb(int r, int g, int b)
1840
Returns the RGB triplet (\a{r}, \a{g}, \a{b}).
1842
The return type QRgb is equivalent to \c unsigned \c int.
1844
\sa qRgba(), qRed(), qGreen(), qBlue()
1848
\fn QRgb qRgba(int r, int g, int b, int a)
1851
Returns the RGBA quadruplet (\a{r}, \a{g}, \a{b}, \a{a}).
1853
The return type QRgba is equivalent to \c unsigned \c int.
1855
\sa qRgb(), qRed(), qGreen(), qBlue()
1859
\fn int qGray(int r, int g, int b)
1862
Returns a gray value (0 to 255) from the (\a r, \a g, \a b) triplet.
1864
The gray value is calculated using the formula (r*11 + g*16 +
1869
\fn int qGray(QRgb rgb)
1873
Returns a gray value (0 to 255) from the given RGB triplet \a rgb.
1877
\fn QColor::QColor(int x, int y, int z, Spec colorSpec)
1879
Use one of the other QColor constructors, or one of the static
1880
convenience functions, instead.
1884
\fn QColor::rgb(int *r, int *g, int *b) const
1886
Use getRgb() instead.
1890
\fn QColor::hsv(int *h, int *s, int *v) const
1892
Use getHsv() instead.
1896
\fn QColor QColor::convertTo(Spec colorSpec) const
1898
Converts the color to the color format specified by \a colorSpec