53 # include "private/qt_x11_p.h" 281 #define QCOLOR_INT_RANGE_CHECK(fn, var) \ 283 if (var < 0 || var > 255) { \ 284 qWarning(#fn": invalid value %d", var); \ 285 var = qMax(0, qMin(var, 255)); \ 289 #define QCOLOR_REAL_RANGE_CHECK(fn, var) \ 291 if (var < qreal(0.0) || var > qreal(1.0)) { \ 292 qWarning(#fn": invalid value %g", var); \ 293 var = qMax(qreal(0.0), qMin(var, qreal(1.0))); \ 357 #define QRGB(r, g, b) \ 358 QRgb(((0xffu << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff))) 359 #define QRGBA(r, g, b, a) \ 360 QRgb(((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)) 362 static const QRgb global_colors[] = {
407 qGreen(global_colors[color]),
408 qBlue(global_colors[color]),
409 qAlpha(global_colors[color]));
436 ct.argb.alpha = 0xffff;
437 ct.argb.red =
qRed(color) * 0x101;
438 ct.argb.green =
qGreen(color) * 0x101;
439 ct.argb.blue =
qBlue(color) * 0x101;
602 #ifndef QT_NO_COLORNAMES 616 setRgb(result.red >> 8, result.green >> 8, result.blue >> 8);
634 #ifndef QT_NO_COLORNAMES 661 *h =
ct.ahsv.hue == USHRT_MAX ?
qreal(-1.0) :
ct.ahsv.hue /
qreal(36000.0);
662 *s =
ct.ahsv.saturation /
qreal(USHRT_MAX);
663 *v =
ct.ahsv.value /
qreal(USHRT_MAX);
666 *a =
ct.ahsv.alpha /
qreal(USHRT_MAX);
689 *h =
ct.ahsv.hue == USHRT_MAX ? -1 :
ct.ahsv.hue / 100;
690 *s =
ct.ahsv.saturation >> 8;
691 *v =
ct.ahsv.value >> 8;
694 *a =
ct.ahsv.alpha >> 8;
712 qWarning(
"QColor::setHsvF: HSV parameters out of range");
717 ct.ahsv.alpha =
qRound(a * USHRT_MAX);
718 ct.ahsv.hue = h ==
qreal(-1.0) ? USHRT_MAX :
qRound(h * 36000);
719 ct.ahsv.saturation =
qRound(s * USHRT_MAX);
720 ct.ahsv.value =
qRound(v * USHRT_MAX);
736 if (h < -1 || (
uint)s > 255 || (
uint)v > 255 || (
uint)a > 255) {
737 qWarning(
"QColor::setHsv: HSV parameters out of range");
743 ct.ahsv.alpha = a * 0x101;
744 ct.ahsv.hue = h == -1 ? USHRT_MAX : (h % 360) * 100;
745 ct.ahsv.saturation = s * 0x101;
746 ct.ahsv.value = v * 0x101;
775 *h =
ct.ahsl.hue == USHRT_MAX ?
qreal(-1.0) :
ct.ahsl.hue /
qreal(36000.0);
776 *s =
ct.ahsl.saturation /
qreal(USHRT_MAX);
777 *l =
ct.ahsl.lightness /
qreal(USHRT_MAX);
780 *a =
ct.ahsl.alpha /
qreal(USHRT_MAX);
808 *h =
ct.ahsl.hue == USHRT_MAX ? -1 :
ct.ahsl.hue / 100;
809 *s =
ct.ahsl.saturation >> 8;
810 *l =
ct.ahsl.lightness >> 8;
813 *a =
ct.ahsl.alpha >> 8;
835 qWarning(
"QColor::setHsvF: HSV parameters out of range");
840 ct.ahsl.alpha =
qRound(a * USHRT_MAX);
841 ct.ahsl.hue = h ==
qreal(-1.0) ? USHRT_MAX :
qRound(h * 36000);
842 ct.ahsl.saturation =
qRound(s * USHRT_MAX);
843 ct.ahsl.lightness =
qRound(l * USHRT_MAX);
863 if (h < -1 || (
uint)s > 255 || (
uint)l > 255 || (
uint)a > 255) {
864 qWarning(
"QColor::setHsv: HSV parameters out of range");
870 ct.ahsl.alpha = a * 0x101;
871 ct.ahsl.hue = h == -1 ? USHRT_MAX : (h % 360) * 100;
872 ct.ahsl.saturation = s * 0x101;
873 ct.ahsl.lightness = l * 0x101;
897 *r =
ct.argb.red /
qreal(USHRT_MAX);
898 *g =
ct.argb.green /
qreal(USHRT_MAX);
899 *b =
ct.argb.blue /
qreal(USHRT_MAX);
902 *a =
ct.argb.alpha /
qreal(USHRT_MAX);
926 *r =
ct.argb.red >> 8;
927 *g =
ct.argb.green >> 8;
928 *b =
ct.argb.blue >> 8;
931 *a =
ct.argb.alpha >> 8;
960 qWarning(
"QColor::setRgbF: RGB parameters out of range");
966 ct.argb.alpha =
qRound(a * USHRT_MAX);
967 ct.argb.red =
qRound(r * USHRT_MAX);
968 ct.argb.green =
qRound(g * USHRT_MAX);
969 ct.argb.blue =
qRound(b * USHRT_MAX);
983 qWarning(
"QColor::setRgb: RGB parameters out of range");
989 ct.argb.alpha = a * 0x101;
990 ct.argb.red = r * 0x101;
991 ct.argb.green = g * 0x101;
992 ct.argb.blue = b * 0x101;
1023 return qRgba(
ct.argb.red >> 8,
ct.argb.green >> 8,
ct.argb.blue >> 8,
ct.argb.alpha >> 8);
1034 ct.argb.alpha =
qAlpha(rgba) * 0x101;
1035 ct.argb.red =
qRed(rgba) * 0x101;
1036 ct.argb.green =
qGreen(rgba) * 0x101;
1037 ct.argb.blue =
qBlue(rgba) * 0x101;
1055 return qRgb(
ct.argb.red >> 8,
ct.argb.green >> 8,
ct.argb.blue >> 8);
1069 ct.argb.alpha = 0xffff;
1070 ct.argb.red =
qRed(rgb) * 0x101;
1071 ct.argb.green =
qGreen(rgb) * 0x101;
1072 ct.argb.blue =
qBlue(rgb) * 0x101;
1083 {
return ct.argb.alpha >> 8; }
1097 ct.argb.alpha = alpha * 0x101;
1107 {
return ct.argb.alpha /
qreal(USHRT_MAX); }
1120 qreal tmp = alpha * USHRT_MAX;
1134 return ct.argb.red >> 8;
1149 ct.argb.red = red * 0x101;
1161 return ct.argb.green >> 8;
1176 ct.argb.green = green * 0x101;
1189 return ct.argb.blue >> 8;
1205 ct.argb.blue = blue * 0x101;
1217 return ct.argb.red /
qreal(USHRT_MAX);
1233 ct.argb.red =
qRound(red * USHRT_MAX);
1245 return ct.argb.green /
qreal(USHRT_MAX);
1261 ct.argb.green =
qRound(green * USHRT_MAX);
1273 return ct.argb.blue /
qreal(USHRT_MAX);
1288 ct.argb.blue =
qRound(blue * USHRT_MAX);
1315 return ct.ahsv.hue == USHRT_MAX ? -1 :
ct.ahsv.hue / 100;
1342 return ct.ahsv.saturation >> 8;
1355 return ct.ahsv.value >> 8;
1381 return ct.ahsv.hue == USHRT_MAX ?
qreal(-1.0) :
ct.ahsv.hue /
qreal(36000.0);
1407 return ct.ahsv.saturation /
qreal(USHRT_MAX);
1420 return ct.ahsv.value /
qreal(USHRT_MAX);
1437 return ct.ahsl.hue == USHRT_MAX ? -1 :
ct.ahsl.hue / 100;
1455 return ct.ahsl.saturation >> 8;
1472 return ct.ahsl.lightness >> 8;
1489 return ct.ahsl.hue == USHRT_MAX ?
qreal(-1.0) :
ct.ahsl.hue /
qreal(36000.0);
1506 return ct.ahsl.saturation /
qreal(USHRT_MAX);
1523 return ct.ahsl.lightness /
qreal(USHRT_MAX);
1536 return ct.acmyk.cyan >> 8;
1549 return ct.acmyk.magenta >> 8;
1562 return ct.acmyk.yellow >> 8;
1576 return ct.acmyk.black >> 8;
1589 return ct.acmyk.cyan /
qreal(USHRT_MAX);
1602 return ct.acmyk.magenta /
qreal(USHRT_MAX);
1615 return ct.acmyk.yellow /
qreal(USHRT_MAX);
1628 return ct.acmyk.black /
qreal(USHRT_MAX);
1643 color.
ct.
argb.alpha =
ct.argb.alpha;
1649 if (
ct.ahsv.saturation == 0 ||
ct.ahsv.hue == USHRT_MAX) {
1656 const qreal h =
ct.ahsv.hue == 36000 ? 0 :
ct.ahsv.hue /
qreal(6000.);
1659 const int i = int(h);
1660 const qreal f = h - i;
1708 if (
ct.ahsl.saturation == 0 ||
ct.ahsl.hue == USHRT_MAX) {
1711 }
else if (
ct.ahsl.lightness == 0) {
1716 const qreal h =
ct.ahsl.hue == 36000 ? 0 :
ct.ahsl.hue /
qreal(36000.);
1722 temp2 = l * (
qreal(1.0) + s);
1724 temp2 = l + s - (l * s);
1731 for (
int i = 0; i != 3; ++i) {
1732 if (temp3[i] <
qreal(0.0))
1733 temp3[i] +=
qreal(1.0);
1734 else if (temp3[i] >
qreal(1.0))
1735 temp3[i] -=
qreal(1.0);
1737 const qreal sixtemp3 = temp3[i] *
qreal(6.0);
1738 if (sixtemp3 <
qreal(1.0))
1739 color.
ct.
array[i+1] =
qRound((temp1 + (temp2 - temp1) * sixtemp3) * USHRT_MAX);
1740 else if ((temp3[i] *
qreal(2.0)) <
qreal(1.0))
1742 else if ((temp3[i] *
qreal(3.0)) <
qreal(2.0))
1773 #define Q_MAX_3(a, b, c) ( ( a > b && a > c) ? a : (b > c ? b : c) ) 1774 #define Q_MIN_3(a, b, c) ( ( a < b && a < c) ? a : (b < c ? b : c) ) 1793 color.
ct.
ahsv.alpha =
ct.argb.alpha;
1801 const qreal delta = max - min;
1805 color.
ct.
ahsv.hue = USHRT_MAX;
1806 color.
ct.
ahsv.saturation = 0;
1810 color.
ct.
ahsv.saturation =
qRound((delta / max) * USHRT_MAX);
1812 hue = ((g - b) /delta);
1814 hue = (
qreal(2.0) + (b - r) / delta);
1816 hue = (
qreal(4.0) + (r - g) / delta);
1818 Q_ASSERT_X(
false,
"QColor::toHsv",
"internal error");
1821 if (hue <
qreal(0.0))
1822 hue +=
qreal(360.0);
1844 color.
ct.
ahsl.alpha =
ct.argb.alpha;
1852 const qreal delta = max - min;
1853 const qreal delta2 = max + min;
1855 color.
ct.
ahsl.lightness =
qRound(lightness * USHRT_MAX);
1858 color.
ct.
ahsl.hue = USHRT_MAX;
1859 color.
ct.
ahsl.saturation = 0;
1863 if (lightness <
qreal(0.5))
1864 color.
ct.
ahsl.saturation =
qRound((delta / delta2) * USHRT_MAX);
1868 hue = ((g - b) /delta);
1870 hue = (
qreal(2.0) + (b - r) / delta);
1872 hue = (
qreal(4.0) + (r - g) / delta);
1874 Q_ASSERT_X(
false,
"QColor::toHsv",
"internal error");
1877 if (hue <
qreal(0.0))
1878 hue +=
qreal(360.0);
1914 c = (c - k) / (
qreal(1.0) - k);
1915 m = (m - k) / (
qreal(1.0) - k);
1916 y = (y - k) / (
qreal(1.0) - k);
1929 if (colorSpec ==
cspec)
1931 switch (colorSpec) {
1990 if (r < 0 || r > 255
1993 || a < 0 || a > 255) {
1994 qWarning(
"QColor::fromRgb: RGB parameters out of range");
2000 color.
ct.
argb.alpha = a * 0x101;
2001 color.
ct.
argb.red = r * 0x101;
2002 color.
ct.
argb.green = g * 0x101;
2003 color.
ct.
argb.blue = b * 0x101;
2023 qWarning(
"QColor::fromRgbF: RGB parameters out of range");
2050 if (((h < 0 || h >= 360) && h != -1)
2053 || a < 0 || a > 255) {
2054 qWarning(
"QColor::fromHsv: HSV parameters out of range");
2060 color.
ct.
ahsv.alpha = a * 0x101;
2061 color.
ct.
ahsv.hue = h == -1 ? USHRT_MAX : (h % 360) * 100;
2062 color.
ct.
ahsv.saturation = s * 0x101;
2063 color.
ct.
ahsv.value = v * 0x101;
2089 qWarning(
"QColor::fromHsvF: HSV parameters out of range");
2120 if (((h < 0 || h >= 360) && h != -1)
2123 || a < 0 || a > 255) {
2124 qWarning(
"QColor::fromHsv: HSV parameters out of range");
2130 color.
ct.
ahsl.alpha = a * 0x101;
2131 color.
ct.
ahsl.hue = h == -1 ? USHRT_MAX : (h % 360) * 100;
2132 color.
ct.
ahsl.saturation = s * 0x101;
2133 color.
ct.
ahsl.lightness = l * 0x101;
2159 qWarning(
"QColor::fromHsvF: HSV parameters out of range");
2167 if (color.
ct.
ahsl.hue == 36000)
2188 if (!c || !m || !y || !k)
2196 *c =
ct.acmyk.cyan >> 8;
2197 *m =
ct.acmyk.magenta >> 8;
2198 *y =
ct.acmyk.yellow >> 8;
2199 *k =
ct.acmyk.black >> 8;
2202 *a =
ct.acmyk.alpha >> 8;
2217 if (!c || !m || !y || !k)
2225 *c =
ct.acmyk.cyan /
qreal(USHRT_MAX);
2226 *m =
ct.acmyk.magenta /
qreal(USHRT_MAX);
2227 *y =
ct.acmyk.yellow /
qreal(USHRT_MAX);
2228 *k =
ct.acmyk.black /
qreal(USHRT_MAX);
2231 *a =
ct.acmyk.alpha /
qreal(USHRT_MAX);
2245 if (c < 0 || c > 255
2249 || a < 0 || a > 255) {
2250 qWarning(
"QColor::setCmyk: CMYK parameters out of range");
2255 ct.acmyk.alpha = a * 0x101;
2256 ct.acmyk.cyan = c * 0x101;
2257 ct.acmyk.magenta = m * 0x101;
2258 ct.acmyk.yellow = y * 0x101;
2259 ct.acmyk.black = k * 0x101;
2283 qWarning(
"QColor::setCmykF: CMYK parameters out of range");
2288 ct.acmyk.alpha =
qRound(a * USHRT_MAX);
2289 ct.acmyk.cyan =
qRound(c * USHRT_MAX);
2290 ct.acmyk.magenta =
qRound(m * USHRT_MAX);
2291 ct.acmyk.yellow =
qRound(y * USHRT_MAX);
2292 ct.acmyk.black =
qRound(k * USHRT_MAX);
2307 if (c < 0 || c > 255
2311 || a < 0 || a > 255) {
2312 qWarning(
"QColor::fromCmyk: CMYK parameters out of range");
2318 color.
ct.
acmyk.alpha = a * 0x101;
2319 color.
ct.
acmyk.cyan = c * 0x101;
2320 color.
ct.
acmyk.magenta = m * 0x101;
2321 color.
ct.
acmyk.yellow = y * 0x101;
2322 color.
ct.
acmyk.black = k * 0x101;
2348 qWarning(
"QColor::fromCmykF: CMYK parameters out of range");
2395 else if (factor < 100)
2396 return darker(10000 / factor);
2399 int s = hsv.
ct.
ahsv.saturation;
2400 int v = hsv.
ct.
ahsv.value;
2403 if (v > USHRT_MAX) {
2411 hsv.
ct.
ahsv.saturation = s;
2451 else if (factor < 100)
2452 return lighter(10000 / factor);
2455 hsv.
ct.
ahsv.value = (hsv.
ct.
ahsv.value * 100) / factor;
2489 return (
ct.argb.alpha == color.
ct.
argb.alpha
2490 && ((((
ct.ahsl.hue % 36000) == (color.
ct.
ahsl.hue % 36000)))
2491 || (
ct.ahsl.hue == color.
ct.
ahsl.hue))
2492 && (
qAbs(
ct.ahsl.saturation - color.
ct.
ahsl.saturation) < 50
2493 ||
ct.ahsl.lightness == 0
2494 || color.
ct.
ahsl.lightness == 0
2495 ||
ct.ahsl.lightness == USHRT_MAX
2496 || color.
ct.
ahsl.lightness == USHRT_MAX)
2497 && (
qAbs(
ct.ahsl.lightness - color.
ct.
ahsl.lightness)) < 50);
2500 &&
ct.argb.alpha == color.
ct.
argb.alpha
2502 && ((
ct.ahsv.hue % 36000) == (color.
ct.
ahsv.hue % 36000)))
2503 || (
ct.ahsv.hue == color.
ct.
ahsv.hue))
2504 &&
ct.argb.green == color.
ct.
argb.green
2505 &&
ct.argb.blue == color.
ct.
argb.blue
2506 &&
ct.argb.pad == color.
ct.
argb.pad);
2566 ct.argb.alpha = USHRT_MAX;
2589 uint QColor::pixel(
int screen)
const 2592 return cmap.
pixel(*
this);
2595 #endif // QT3_SUPPORT 2601 #ifndef QT_NO_DEBUG_STREAM 2604 #ifndef Q_BROKEN_DEBUG_STREAM 2606 dbg.
nospace() <<
"QColor(Invalid)";
2619 qWarning(
"This compiler doesn't support streaming QColor to QDebug");
2626 #ifndef QT_NO_DATASTREAM 2642 return stream <<
quint32(0x49000000);
2645 p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
2682 if (p == 0x49000000) {
2687 p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
2710 #endif // QT_NO_DATASTREAM The QVariant class acts like a union for the most common Qt data types.
The QDebug class provides an output stream for debugging information.
void setRed(int red)
Sets the red color component of this color to red.
The QColor class provides colors based on RGB, HSV or CMYK values.
qreal cyanF() const
Returns the cyan color component of this color.
void setRgb(int r, int g, int b, int a=255)
Sets the RGB value to r, g, b and the alpha value to a.
QColor & operator=(const QColor &)
Assigns a copy of color to this color, and returns a reference to it.
static QColormap instance(int screen=-1)
qreal alphaF() const
Returns the alpha color component of this color.
QStringList qt_get_colornames()
QString & sprintf(const char *format,...)
Safely builds a formatted string from the format string cformat and an arbitrary list of arguments...
qreal hslHueF() const
Returns the hue color component of this color.
void setNamedColor(const QString &name)
Sets the RGB value of this QColor to name, which may be in one of these formats:
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
QColor toCmyk() const
Creates and returns a CMYK QColor based on this color.
#define QT_END_NAMESPACE
This macro expands to.
ushort hue
Returns the hue color component of this color.
friend Q_GUI_EXPORT QDataStream & operator<<(QDataStream &, const QColor &)
Writes the color to the stream.
void getCmyk(int *c, int *m, int *y, int *k, int *a=0)
Sets the contents pointed to by c, m, y, k, and a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components of the color's CMYK value.
struct QColor::@220::@224 ahsl
qreal valueF() const
Returns the value color component of this color.
qreal greenF() const
Returns the green color component of this color.
static QColor fromCmykF(qreal c, qreal m, qreal y, qreal k, qreal a=1.0)
Static convenience function that returns a QColor constructed from the given CMYK color values: c (cy...
int hslHue() const
Returns the hue color component of this color.
QDebug & nospace()
Clears the stream's internal flag that records whether the last character was a space and returns a r...
Spec
The type of color specified, either RGB, HSV, CMYK or HSL.
int length() const
Returns the number of characters in this string.
static QColor fromHsv(int h, int s, int v, int a=255)
Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), v (value), and a (alpha-channel, i.e.
void setRgbF(qreal r, qreal g, qreal b, qreal a=1.0)
Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency).
ushort lightness
Returns the lightness color component of this color.
void setGreen(int green)
Sets the green color component of this color to green.
int hslSaturation() const
Returns the saturation color component of this color.
qreal blackF() const
Returns the black color component of this color.
static QColor fromHsvF(qreal h, qreal s, qreal v, qreal a=1.0)
Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), v (value), and a (alpha-channel, i.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
qreal lightnessF() const
Returns the lightness color component of this color.
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
long ASN1_INTEGER_get ASN1_INTEGER * a
qreal hslSaturationF() const
Returns the saturation color component of this color.
struct QColor::@220::@221 argb
qreal hsvHueF() const
Returns the hue color component of this color.
void invalidate()
Marks the color as invalid and sets all components to zero (alpha is set to fully opaque for compatib...
void setGreenF(qreal green)
Sets the green color component of this color to green.
qreal saturationF() const
Returns the saturation color component of this color.
ushort red
Returns the red color component of this color.
The QString class provides a Unicode character string.
void getHsl(int *h, int *s, int *l, int *a=0) const
Sets the contents pointed to by h, s, l, and a, to the hue, saturation, lightness, and alpha-channel (transparency) components of the color's HSL value.
QColor toHsv() const
Creates and returns an HSV QColor based on this color.
Q_DECL_CONSTEXPR T qAbs(const T &t)
void setRedF(qreal red)
Sets the red color component of this color to red.
void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a=0)
Sets the contents pointed to by c, m, y, k, and a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components of the color's CMYK value.
qreal hsvSaturationF() const
Returns the saturation color component of this color.
int qRed(QRgb rgb)
Returns the red component of the ARGB quadruplet rgb.
void setHslF(qreal h, qreal s, qreal l, qreal a=1.0)
Sets a HSL color lightness; h is the hue, s is the saturation, l is the lightness and a is the alpha ...
void getHsv(int *h, int *s, int *v, int *a=0) const
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (tra...
void setHsv(int h, int s, int v, int a=255)
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha componen...
int qAlpha(QRgb rgba)
Returns the alpha component of the ARGB quadruplet rgba.
ushort yellow
Returns the yellow color component of this color.
ushort magenta
Returns the magenta color component of this color.
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
void getRgbF(qreal *r, qreal *g, qreal *b, qreal *a=0) const
Sets the contents pointed to by r, g, b, and a, to the red, green, blue, and alpha-channel (transpare...
bool qt_get_named_rgb(const char *name, QRgb *rgb)
void setHsvF(qreal h, qreal s, qreal v, qreal a=1.0)
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha componen...
static bool allowX11ColorNames()
Returns true if setNamedColor() is allowed to look up colors in the X11 color database.
#define QT_BEGIN_NAMESPACE
This macro expands to.
struct QColor::@220::@222 ahsv
ushort value
Returns the value color component of this color.
bool setColorFromString(const QString &name)
static QColor fromRgba(QRgb rgba)
Static convenience function that returns a QColor constructed from the given QRgb value rgba...
static bool isValidColor(const QString &name)
Returns true if the name is a valid color name and can be used to construct a valid QColor object...
ushort saturation
Returns the saturation color component of this color.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void setHsl(int h, int s, int l, int a=255)
Sets a HSL color value; h is the hue, s is the saturation, l is the lightness and a is the alpha comp...
void setBlueF(qreal blue)
Sets the blue color component of this color to blue.
QColor dark(int f=200) const
Use darker(factor) instead.
void setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a=1.0)
Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel...
The QStringList class provides a list of strings.
friend Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QColor &)
Reads the color from the stream.
int hsvHue() const
Returns the hue color component of this color.
Q_CORE_EXPORT void qWarning(const char *,...)
static QColor fromHslF(qreal h, qreal s, qreal l, qreal a=1.0)
Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), l (lightness), and a (alpha-channel, i.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
static QColor fromRgbF(qreal r, qreal g, qreal b, qreal a=1.0)
Static convenience function that returns a QColor constructed from the RGB color values, r (red), g (green), b (blue), and a (alpha-channel, i.e.
static Qt::HANDLE appColormap(int screen=-1)
Returns a handle for the application's color map on the given screen.
static void setAllowX11ColorNames(bool enabled)
Allow setNamedColor() to look up colors in the X11 color database if enabled.
void setBlue(int blue)
Sets the blue color component of this color to blue.
uint pixel(const QColor &color) const
void setRgba(QRgb rgba)
Use setRgb() instead.
#define QRGBA(r, g, b, a)
qreal yellowF() const
Returns the yellow color component of this color.
qreal hueF() const
Returns the hue color component of this color.
int version() const
Returns the version number of the data serialization format.
static QColor fromHsl(int h, int s, int l, int a=255)
Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), l (lightness), and a (alpha-channel, i.
QColor toRgb() const
Create and returns an RGB QColor based on this color.
bool operator==(const QColor &c) const
Returns true if this color has the same RGB and alpha values as color; otherwise returns false...
const char * constData() const
Returns a pointer to the data stored in the byte array.
QRgb qRgb(int r, int g, int b)
Returns the ARGB quadruplet (255, {r}, {g}, {b}).
#define Q_ASSERT_X(cond, where, what)
ushort blue
Returns the blue color component of this color.
void setAlphaF(qreal alpha)
Sets the alpha of this color to alpha.
static QColor fromCmyk(int c, int m, int y, int k, int a=255)
Static convenience function that returns a QColor constructed from the given CMYK color values: c (cy...
static QCoreApplication * instance()
Returns a pointer to the application's QCoreApplication (or QApplication) instance.
qreal redF() const
Returns the red color component of this color.
static bool allowX11ColorNames
QColor convertTo(Spec colorSpec) const
Creates a copy of this color in the format specified by colorSpec.
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
qreal blueF() const
Returns the blue color component of this color.
void getHsvF(qreal *h, qreal *s, qreal *v, qreal *a=0) const
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (tra...
void getRgb(int *r, int *g, int *b, int *a=0) const
Sets the contents pointed to by r, g, b, and a, to the red, green, blue, and alpha-channel (transpare...
static QColor fromRgb(QRgb rgb)
Static convenience function that returns a QColor constructed from the given QRgb value rgb...
ushort black
Returns the black color component of this color.
static QStringList colorNames()
Returns a QStringList containing the color names Qt knows about.
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
QColor()
Constructs an invalid color with the RGB value (0, 0, 0).
int hsvSaturation() const
Returns the saturation color component of this color.
The QDataStream class provides serialization of binary data to a QIODevice.
bool isValid() const
Returns true if the color is valid; otherwise returns false.
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
QColor toHsl() const
Creates and returns an HSL QColor based on this color.
int qGreen(QRgb rgb)
Returns the green component of the ARGB quadruplet rgb.
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
int qBlue(QRgb rgb)
Returns the blue component of the ARGB quadruplet rgb.
#define QCOLOR_INT_RANGE_CHECK(fn, var)
ushort cyan
Returns the cyan color component of this color.
bool operator!=(const QColor &c) const
Returns true if this color has a different RGB and alpha values from color; otherwise returns false...
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
qreal magentaF() const
Returns the magenta color component of this color.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
ushort green
Returns the green color component of this color.
bool qt_get_hex_rgb(const char *name, QRgb *rgb)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QString name() const
Returns the name of the color in the format "#RRGGBB"; i.e.
#define QCOLOR_REAL_RANGE_CHECK(fn, var)
const QChar * constData() const
Returns a pointer to the data stored in the QString.
QRgb rgb() const
Returns the RGB value of the color.
QRgb qRgba(int r, int g, int b, int a)
Returns the ARGB quadruplet ({a}, {r}, {g}, {b}).
Q_DECL_CONSTEXPR int qRound(qreal d)
static Display * display()
Returns the default display for the application.
void getHslF(qreal *h, qreal *s, qreal *l, qreal *a=0) const
Sets the contents pointed to by h, s, l, and a, to the hue, saturation, lightness, and alpha-channel (transparency) components of the color's HSL value.
struct QColor::@220::@223 acmyk
QColor light(int f=150) const
Use lighter(factor) instead.
Spec spec() const
Returns how the color was specified.
void setCmyk(int c, int m, int y, int k, int a=255)
Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel...