Qt 4.8
|
The QColor class provides colors based on RGB, HSV or CMYK values. More...
#include <qcolor.h>
Public Types | |
enum | Spec { Invalid, Rgb, Hsv, Cmyk, Hsl } |
The type of color specified, either RGB, HSV, CMYK or HSL. More... | |
Public Functions | |
int | alpha () const |
qreal | alphaF () const |
Returns the alpha color component of this color. More... | |
int | black () const |
qreal | blackF () const |
Returns the black color component of this color. More... | |
int | blue () const |
qreal | blueF () const |
Returns the blue color component of this color. More... | |
QColor | convertTo (Spec colorSpec) const |
Creates a copy of this color in the format specified by colorSpec. More... | |
int | cyan () const |
qreal | cyanF () const |
Returns the cyan color component of this color. More... | |
QColor | dark (int f=200) const |
Use darker(factor) instead. More... | |
QColor | darker (int f=200) const |
Returns a darker (or lighter) color, but does not change this object. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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 (transparency) components of the color's HSV value. More... | |
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 (transparency) components of the color's HSV value. More... | |
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 (transparency) components of the color's RGB value. More... | |
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 (transparency) components of the color's RGB value. More... | |
int | green () const |
qreal | greenF () const |
Returns the green color component of this color. More... | |
int | hslHue () const |
Returns the hue color component of this color. More... | |
qreal | hslHueF () const |
Returns the hue color component of this color. More... | |
int | hslSaturation () const |
Returns the saturation color component of this color. More... | |
qreal | hslSaturationF () const |
Returns the saturation color component of this color. More... | |
int | hsvHue () const |
Returns the hue color component of this color. More... | |
qreal | hsvHueF () const |
Returns the hue color component of this color. More... | |
int | hsvSaturation () const |
Returns the saturation color component of this color. More... | |
qreal | hsvSaturationF () const |
Returns the saturation color component of this color. More... | |
int | hue () const |
qreal | hueF () const |
Returns the hue color component of this color. More... | |
bool | isValid () const |
Returns true if the color is valid; otherwise returns false. More... | |
QColor | light (int f=150) const |
Use lighter(factor) instead. More... | |
QColor | lighter (int f=150) const |
Returns a lighter (or darker) color, but does not change this object. More... | |
int | lightness () const |
qreal | lightnessF () const |
Returns the lightness color component of this color. More... | |
int | magenta () const |
qreal | magentaF () const |
Returns the magenta color component of this color. More... | |
QString | name () const |
Returns the name of the color in the format "#RRGGBB"; i.e. More... | |
operator QVariant () const | |
Returns the color as a QVariant. More... | |
bool | operator!= (const QColor &c) const |
Returns true if this color has a different RGB and alpha values from color; otherwise returns false. More... | |
QColor & | operator= (const QColor &) |
Assigns a copy of color to this color, and returns a reference to it. More... | |
QColor & | operator= (Qt::GlobalColor color) |
Assigns a copy of color and returns a reference to this color. More... | |
bool | operator== (const QColor &c) const |
Returns true if this color has the same RGB and alpha values as color; otherwise returns false. More... | |
QColor () | |
Constructs an invalid color with the RGB value (0, 0, 0). More... | |
QColor (Qt::GlobalColor color) | |
Constructs a new color with a color value of color. More... | |
QColor (int r, int g, int b, int a=255) | |
Constructs a color with the RGB value r, g, b, and the alpha-channel (transparency) value of a. More... | |
QColor (QRgb rgb) | |
Constructs a color with the value color. More... | |
QColor (const QString &name) | |
Constructs a named color in the same way as setNamedColor() using the given name. More... | |
QColor (const char *name) | |
Constructs a named color in the same way as setNamedColor() using the given name. More... | |
QColor (const QColor &color) | |
Constructs a color that is a copy of color. More... | |
QColor (Spec spec) | |
Constructs a color with the given spec. More... | |
int | red () const |
qreal | redF () const |
Returns the red color component of this color. More... | |
QRgb | rgb () const |
Returns the RGB value of the color. More... | |
QRgb | rgba () const |
Returns the RGB value of the color, including its alpha. More... | |
int | saturation () const |
qreal | saturationF () const |
Returns the saturation color component of this color. More... | |
void | setAlpha (int alpha) |
Sets the alpha of this color to alpha. More... | |
void | setAlphaF (qreal alpha) |
Sets the alpha of this color to alpha. More... | |
void | setBlue (int blue) |
Sets the blue color component of this color to blue. More... | |
void | setBlueF (qreal blue) |
Sets the blue color component of this color to blue. More... | |
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, i.e. More... | |
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, i. More... | |
void | setGreen (int green) |
Sets the green color component of this color to green. More... | |
void | setGreenF (qreal green) |
Sets the green color component of this color to green. More... | |
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 component of the HSL color. More... | |
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 component of the HSL color. More... | |
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 component of the HSV color. More... | |
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 component of the HSV color. More... | |
void | setNamedColor (const QString &name) |
Sets the RGB value of this QColor to name, which may be in one of these formats: More... | |
void | setRed (int red) |
Sets the red color component of this color to red. More... | |
void | setRedF (qreal red) |
Sets the red color component of this color to red. More... | |
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. More... | |
void | setRgb (QRgb rgb) |
Sets the RGB value to rgb. More... | |
void | setRgba (QRgb rgba) |
Use setRgb() instead. More... | |
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). More... | |
Spec | spec () const |
Returns how the color was specified. More... | |
QColor | toCmyk () const |
Creates and returns a CMYK QColor based on this color. More... | |
QColor | toHsl () const |
Creates and returns an HSL QColor based on this color. More... | |
QColor | toHsv () const |
Creates and returns an HSV QColor based on this color. More... | |
QColor | toRgb () const |
Create and returns an RGB QColor based on this color. More... | |
int | value () const |
qreal | valueF () const |
Returns the value color component of this color. More... | |
int | yellow () const |
qreal | yellowF () const |
Returns the yellow color component of this color. More... | |
Static Public Functions | |
static bool | allowX11ColorNames () |
Returns true if setNamedColor() is allowed to look up colors in the X11 color database. More... | |
static QStringList | colorNames () |
Returns a QStringList containing the color names Qt knows about. More... | |
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 (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e. More... | |
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 (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
static QColor | fromRgb (QRgb rgb) |
Static convenience function that returns a QColor constructed from the given QRgb value rgb. More... | |
static QColor | fromRgb (int r, int g, int b, int a=255) |
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. More... | |
static QColor | fromRgba (QRgb rgba) |
Static convenience function that returns a QColor constructed from the given QRgb value rgba. More... | |
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. More... | |
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, otherwise returns false. More... | |
static void | setAllowX11ColorNames (bool enabled) |
Allow setNamedColor() to look up colors in the X11 color database if enabled. More... | |
Private Functions | |
void | invalidate () |
Marks the color as invalid and sets all components to zero (alpha is set to fully opaque for compatibility with Qt 3). More... | |
QColor (int, int, int, Spec) | |
Use one of the other QColor constructors, or one of the static convenience functions, instead. More... | |
bool | setColorFromString (const QString &name) |
Properties | |
Spec | cspec |
union { | |
struct { | |
ushort alpha | |
ushort black | |
ushort cyan | |
ushort magenta | |
ushort yellow | |
} acmyk | |
struct { | |
ushort alpha | |
ushort hue | |
ushort lightness | |
ushort pad | |
ushort saturation | |
} ahsl | |
struct { | |
ushort alpha | |
ushort hue | |
ushort pad | |
ushort saturation | |
ushort value | |
} ahsv | |
struct { | |
ushort alpha | |
ushort blue | |
ushort green | |
ushort pad | |
ushort red | |
} argb | |
ushort array [5] | |
} | ct |
Friends | |
Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &, const QColor &) |
Writes the color to the stream. More... | |
Q_GUI_EXPORT QDataStream & | operator>> (QDataStream &, QColor &) |
Reads the color from the stream. More... | |
class | QColormap |
Related Functions | |
(Note that these are not member functions.) | |
int | qAlpha (QRgb rgba) |
Returns the alpha component of the ARGB quadruplet rgba. More... | |
int | qBlue (QRgb rgb) |
Returns the blue component of the ARGB quadruplet rgb. More... | |
int | qGray (int r, int g, int b) |
int | qGray (QRgb rgb) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
int | qGreen (QRgb rgb) |
Returns the green component of the ARGB quadruplet rgb. More... | |
int | qRed (QRgb rgb) |
Returns the red component of the ARGB quadruplet rgb. More... | |
QRgb | qRgb (int r, int g, int b) |
Returns the ARGB quadruplet (255, {r}, {g}, {b}). More... | |
QRgb | |
An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int. More... | |
QRgb | qRgba (int r, int g, int b, int a) |
Returns the ARGB quadruplet ({a}, {r}, {g}, {b}). More... | |
The QColor class provides colors based on RGB, HSV or CMYK values.
A color is normally specified in terms of RGB (red, green, and blue) components, but it is also possible to specify it in terms of HSV (hue, saturation, and value) and CMYK (cyan, magenta, yellow and black) components. In addition a color can be specified using a color name. The color name can be any of the SVG 1.0 color names.
RGB | HSV | CMYK |
The QColor constructor creates the color based on RGB values. To create a QColor based on either HSV or CMYK values, use the toHsv() and toCmyk() functions respectively. These functions return a copy of the color using the desired format. In addition the static fromRgb(), fromHsv() and fromCmyk() functions create colors from the specified values. Alternatively, a color can be converted to any of the three formats using the convertTo() function (returning a copy of the color in the desired format), or any of the setRgb(), setHsv() and setCmyk() functions altering this color's format. The spec() function tells how the color was specified.
A color can be set by passing an RGB string (such as "#112233"), or a color name (such as "blue"), to the setNamedColor() function. The color names are taken from the SVG 1.0 color names. The name() function returns the name of the color in the format "#RRGGBB". Colors can also be set using setRgb(), setHsv() and setCmyk(). To get a lighter or darker color use the lighter() and darker() functions respectively.
The isValid() function indicates whether a QColor is legal at all. For example, a RGB color with RGB values out of range is illegal. For performance reasons, QColor mostly disregards illegal colors, and for that reason, the result of using an invalid color is undefined.
The color components can be retrieved individually, e.g with red(), hue() and cyan(). The values of the color components can also be retrieved in one go using the getRgb(), getHsv() and getCmyk() functions. Using the RGB color model, the color components can in addition be accessed with rgb().
There are several related non-members: QRgb is a typdef for an unsigned int representing the RGB value triplet (r, g, b). Note that it also can hold a value for the alpha-channel (for more information, see the Alpha-Blended Drawing section). The qRed(), qBlue() and qGreen() functions return the respective component of the given QRgb value, while the qRgb() and qRgba() functions create and return the QRgb triplet based on the given component values. Finally, the qAlpha() function returns the alpha component of the provided QRgb, and the qGray() function calculates and return a gray value based on the given value.
QColor is platform and device independent. The QColormap class maps the color to the hardware.
For more information about painting in general, see the Paint System documentation.
QColor supports floating point precision and provides floating point versions of all the color components functions, e.g. getRgbF(), hueF() and fromCmykF(). Note that since the components are stored using 16-bit integers, there might be minor deviations between the values set using, for example, setRgbF() and the values returned by the getRgbF() function due to rounding.
While the integer based functions take values in the range 0-255 (except hue() which must have values within the range 0-359), the floating point functions accept values in the range 0.0 - 1.0.
QColor also support alpha-blended outlining and filling. The alpha channel of a color specifies the transparency effect, 0 represents a fully transparent color, while 255 represents a fully opaque color. For example:
The code above produces the following output:
Alpha-blended drawing is supported on Windows, Mac OS X, and on X11 systems that have the X Render extension installed.
The alpha channel of a color can be retrieved and set using the alpha() and setAlpha() functions if its value is an integer, and alphaF() and setAlphaF() if its value is qreal (double). By default, the alpha-channel is set to 255 (opaque). To retrieve and set all the RGB color components (including the alpha-channel) in one go, use the rgba() and setRgba() functions.
There are 20 predefined QColors described by the Qt::GlobalColor enum, including black, white, primary and secondary colors, darker versions of these colors and three shades of gray. QColor also recognizes a variety of color names; the static colorNames() function returns a QStringList color names that QColor knows about.
Additionally, the Qt::color0, Qt::color1 and Qt::transparent colors are used for special purposes.
Qt::color0 (zero pixel value) and Qt::color1 (non-zero pixel value) are special colors for drawing in QBitmaps. Painting with Qt::color0 sets the bitmap bits to 0 (transparent; i.e., background), and painting with Qt::color1 sets the bits to 1 (opaque; i.e., foreground).
Qt::transparent is used to indicate a transparent pixel. When painting with this value, a pixel value will be used that is appropriate for the underlying pixel format in use.
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 the human perception of color. For example, the relationships "stronger than", "darker than", and "the opposite of" are easily expressed in HSV but are much harder to express in RGB.
HSV, like RGB, has three components:
H, for hue, is in the range 0 to 359 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.
S, for saturation, is in the range 0 to 255, and the bigger it is, the stronger the color is. Grayish colors have saturation near 0; very strong colors have saturation near 255.
V, for value, is in the range 0 to 255 and represents lightness or brightness of the color. 0 is black; 255 is as far from black as possible.
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.
Qt returns a hue value of -1 for achromatic colors. If you pass a hue value that is too large, Qt forces it into range. Hue 360 or 720 is treated as 0; hue 540 is treated as 180.
In addition to the standard HSV model, Qt provides an alpha-channel to feature alpha-blended drawing.
HSL is similar to HSV. Instead of value parameter from HSV, HSL has the lightness parameter. The lightness parameter goes from black to color and from color to white. If you go outside at the night its black or dark gray. At day its colorful but if you look in a really strong light a things they are going to white and wash out.
While the RGB and HSV color models are used for display on computer monitors, the CMYK model is used in the four-color printing process of printing presses and some hard-copy devices.
CMYK has four components, all in the range 0-255: cyan (C), magenta (M), yellow (Y) and black (K). Cyan, magenta and yellow are called subtractive colors; the CMYK color model creates color by starting with a white surface and then subtracting color by applying the appropriate components. While combining cyan, magenta and yellow gives the color black, subtracting one or more will yield any other color. When combined in various percentages, these three colors can create the entire spectrum of colors.
Mixing 100 percent of cyan, magenta and yellow does produce black, but the result is unsatisfactory since it wastes ink, increases drying time, and gives a muddy colour when printing. For that reason, black is added in professional printing to provide a solid black tone; hence the term 'four color process'.
In addition to the standard CMYK model, Qt provides an alpha-channel to feature alpha-blended drawing.
enum QColor::Spec |
The type of color specified, either RGB, HSV, CMYK or HSL.
Enumerator | |
---|---|
Invalid | |
Rgb | |
Hsv | |
Cmyk | |
Hsl |
Definition at line 70 of file qcolor.h.
|
inline |
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.
The alpha value of an invalid color is unspecified.
Definition at line 279 of file qcolor.h.
Referenced by convertTo(), fromCmyk(), fromCmykF(), fromHsl(), fromHslF(), fromHsv(), fromHsvF(), fromRgb(), fromRgbF(), isValidColor(), and operator=().
QColor::QColor | ( | Qt::GlobalColor | color | ) |
Constructs a new color with a color value of color.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 355 of file qcolor.cpp.
|
inline |
Constructs a color with the RGB value r, g, b, and the alpha-channel (transparency) value of a.
The color is left invalid if any of the arguments are invalid.
Definition at line 282 of file qcolor.h.
QColor::QColor | ( | QRgb | color | ) |
Constructs a color with the value color.
The alpha component is ignored and set to solid.
Definition at line 433 of file qcolor.cpp.
|
inline |
Constructs a named color in the same way as setNamedColor() using the given name.
The color is left invalid if the name cannot be parsed.
Definition at line 288 of file qcolor.h.
|
inline |
Constructs a named color in the same way as setNamedColor() using the given name.
The color is left invalid if the name cannot be parsed.
Definition at line 285 of file qcolor.h.
|
inline |
QColor::QColor | ( | Spec | spec | ) |
Constructs a color with the given spec.
This function is primarly present to avoid that QColor::Invalid becomes a valid color by accident.
Definition at line 456 of file qcolor.cpp.
|
private |
Use one of the other QColor constructors, or one of the static convenience functions, instead.
|
static |
Returns true if setNamedColor() is allowed to look up colors in the X11 color database.
By default, this function returns false.
Definition at line 2535 of file qcolor.cpp.
Referenced by qt_set_x11_resources(), setAllowX11ColorNames(), and setColorFromString().
int QColor::alpha | ( | ) | const |
Referenced by setBlue(), setGreen(), setRed(), and setRgb().
qreal QColor::alphaF | ( | ) | const |
Returns the alpha color component of this color.
Definition at line 1106 of file qcolor.cpp.
Referenced by QGLPixmapGLPaintDevice::beginPaint(), QGLWidgetGLPaintDevice::beginPaint(), QVGPaintEngine::clearRect(), QVGPixmapColorizeFilter::draw(), QGL2PaintEngineExPrivate::drawCachedGlyphs(), QMacStyle::drawComplexControl(), QMacStyle::drawControl(), QVGCompositionHelper::fillBackground(), QVGPaintEngine::fillRegion(), QTextControlPrivate::inputMethodEvent(), operator<<(), QLineControl::processInputMethodEvent(), qBrushSetAlphaF(), qt_premultiplyColor(), QInternalMimeData::renderDataHelper(), QGLShaderProgram::setAttributeValue(), setBlueF(), QVGPaintEnginePrivate::setBrush(), setGreenF(), setRedF(), QGLPixmapDropShadowFilter::setUniforms(), QGLShaderProgram::setUniformValue(), QVGPaintEnginePrivate::setupColorRamp(), QDeclarativeEnginePrivate::tint(), and translate_color().
int QColor::black | ( | ) | const |
Referenced by lightnessF().
qreal QColor::blackF | ( | ) | const |
Returns the black color component of this color.
Definition at line 1624 of file qcolor.cpp.
Referenced by blackF(), and operator<<().
int QColor::blue | ( | ) | const |
Referenced by name(), setGreen(), and setRed().
qreal QColor::blueF | ( | ) | const |
Returns the blue color component of this color.
Definition at line 1269 of file qcolor.cpp.
Referenced by QGLPixmapGLPaintDevice::beginPaint(), QGLWidgetGLPaintDevice::beginPaint(), blueF(), QVGPaintEngine::clearRect(), QVGPixmapColorizeFilter::draw(), QGL2PaintEngineExPrivate::drawCachedGlyphs(), QMacStyle::drawComplexControl(), QMacStyle::drawControl(), QVGCompositionHelper::fillBackground(), QVGPaintEngine::fillRegion(), operator<<(), qt_premultiplyColor(), QInternalMimeData::renderDataHelper(), QGLShaderProgram::setAttributeValue(), QPSPrintEngine::setBrush(), QPdfEngine::setBrush(), QVGPaintEnginePrivate::setBrush(), setGreenF(), setRedF(), QGLPixmapDropShadowFilter::setUniforms(), QGLShaderProgram::setUniformValue(), QVGPaintEnginePrivate::setupColorRamp(), and QDeclarativeEnginePrivate::tint().
|
static |
Returns a QStringList containing the color names Qt knows about.
Definition at line 632 of file qcolor.cpp.
QColor QColor::convertTo | ( | QColor::Spec | colorSpec | ) | const |
Creates a copy of this color in the format specified by colorSpec.
Definition at line 1927 of file qcolor.cpp.
Referenced by dark(), and light().
int QColor::cyan | ( | ) | const |
Referenced by lightnessF().
qreal QColor::cyanF | ( | ) | const |
Returns the cyan color component of this color.
Definition at line 1585 of file qcolor.cpp.
Referenced by cyanF(), and operator<<().
QColor QColor::dark | ( | int | factor = 200 | ) | const |
Use darker(factor) instead.
Definition at line 2447 of file qcolor.cpp.
Referenced by darker(), QWindowsCEStyle::drawComplexControl(), QWindowsMobileStyle::drawComplexControl(), QWindowsStyle::drawComplexControl(), QWindowsCEStyle::drawControl(), QWindowsStyle::drawControl(), QGtkStyle::drawPrimitive(), and qt_set_windows_color_resources().
|
inline |
Returns a darker (or lighter) color, but does not change this object.
If the factor is greater than 100, this functions returns a darker color. Setting factor to 300 returns a color that has one-third the brightness. If the factor is less than 100, the return color is lighter, but we recommend using the lighter() function for this purpose. If the factor is 0 or negative, the return value is unspecified.
The function converts the current RGB color to HSV, divides the value (V) component by factor and converts the color back to RGB.
Definition at line 301 of file qcolor.h.
Referenced by QRenderRule::configurePalette(), QDeclarativeEnginePrivate::darker(), QPlastiqueStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QWindowsVistaStyle::drawControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsXPStyle::drawControl(), QMacStyle::drawControl(), QStyleHelper::drawDial(), QWindowsVistaStyle::drawPrimitive(), QPlastiqueStyle::drawPrimitive(), QCleanlooksStyle::drawPrimitive(), QGtkStyle::drawPrimitive(), QMacStyle::drawPrimitive(), light(), QWindowsXPStyle::polish(), QMotifStyle::polish(), QWindowsVistaStyle::polish(), qBrushDark(), qt_cleanlooks_draw_buttongradient(), qt_cleanlooks_draw_mdibutton(), qt_plastique_draw_handle(), qt_plastique_drawFrame(), qt_plastique_drawShadedPanel(), qt_set_windows_color_resources(), QCleanlooksStyle::standardPalette(), QCDEStyle::standardPalette(), QGtkStyle::standardPalette(), QPlastiqueStyle::standardPalette(), QStyle::standardPalette(), QWindowsVistaStyle::styleHint(), and QCleanlooksStyle::styleHint().
|
static |
Static convenience function that returns a QColor constructed from the given CMYK color values: c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e.
transparency).
All the values must be in the range 0-255.
Definition at line 2305 of file qcolor.cpp.
Static convenience function that returns a QColor constructed from the given CMYK color values: c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
e. transparency).
All the values must be in the range 0.0-1.0. \sa toCmyk(), fromCmyk(), isValid(), {QColor#The CMYK Color Model}{The CMYK Color Model}
Definition at line 2341 of file qcolor.cpp.
|
static |
Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), l (lightness), and a (alpha-channel, i.
e. transparency).
The value of \a s, \a l, and \a a must all be in the range 0-255; the value of \a h must be in the range 0-359. \sa toHsl(), fromHslF(), isValid()
Definition at line 2118 of file qcolor.cpp.
Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), l (lightness), and a (alpha-channel, i.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
e. transparency).
All the values must be in the range 0.0-1.0. \sa toHsl(), fromHsl(), isValid()
Definition at line 2153 of file qcolor.cpp.
Referenced by QDeclarativeEnginePrivate::hsla().
|
static |
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.
transparency).
The value of s, v, and a must all be in the range 0-255; the value of h must be in the range 0-359.
Definition at line 2048 of file qcolor.cpp.
Referenced by QGraphicsScenePrivate::draw(), and parseColorValue().
Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), v (value), and a (alpha-channel, i.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
e. transparency).
All the values must be in the range 0.0-1.0. \sa toHsv(), fromHsv(), isValid(), {QColor#The HSV Color Model}{The HSV Color Model}
Definition at line 2083 of file qcolor.cpp.
Static convenience function that returns a QColor constructed from the given QRgb value rgb.
The alpha component of rgb is ignored (i.e. it is automatically set to 255), use the fromRgba() function to include the alpha-channel specified by the given QRgb value.
Definition at line 1958 of file qcolor.cpp.
Referenced by fromRgba(), parseColorValue(), QmlJSDebugger::ColorPickerTool::pickColor(), and QWindowsVistaStyle::polish().
|
static |
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.
transparency).
All the values must be in the range 0-255.
Definition at line 1988 of file qcolor.cpp.
Static convenience function that returns a QColor constructed from the given QRgb value rgba.
Unlike the fromRgb() function, the alpha-channel specified by the given QRgb value is included.
Definition at line 1974 of file qcolor.cpp.
Referenced by QSvgPaintEngine::saveGradientStops().
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.
transparency).
All the values must be in the range 0.0-1.0.
Definition at line 2017 of file qcolor.cpp.
Referenced by QGL2PaintEngineExPrivate::drawCachedGlyphs(), query_colormap(), and QDeclarativeEnginePrivate::rgba().
void QColor::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.
These components can be retrieved individually using the cyan(), magenta(), yellow(), black() and alpha() functions.
Definition at line 2186 of file qcolor.cpp.
Referenced by getCmyk().
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.
These components can be retrieved individually using the cyanF(), magentaF(), yellowF(), blackF() and alphaF() functions.
Definition at line 2215 of file qcolor.cpp.
Referenced by getCmykF().
void QColor::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.
These components can be retrieved individually using the hueHsl(), saturationHsl(), lightness() and alpha() functions.
Definition at line 798 of file qcolor.cpp.
Referenced by getHsl().
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.
These components can be retrieved individually using the hueHslF(), saturationHslF(), lightnessF() and alphaF() functions.
Definition at line 765 of file qcolor.cpp.
Referenced by getHslF().
void QColor::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 (transparency) components of the color's HSV value.
These components can be retrieved individually using the hue(), saturation(), value() and alpha() functions.
Definition at line 679 of file qcolor.cpp.
Referenced by darkenPixmap(), QCommonStyle::drawPrimitive(), getHsv(), QPalette::QPalette(), qt_palette_from_color(), and rgb2hsv().
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (transparency) components of the color's HSV value.
These components can be retrieved individually using the hueF(), saturationF(), valueF() and alphaF() functions.
Definition at line 651 of file qcolor.cpp.
Referenced by getHsvF().
void QColor::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 (transparency) components of the color's RGB value.
These components can be retrieved individually using the red(), green(), blue() and alpha() functions.
Definition at line 916 of file qcolor.cpp.
Referenced by getRgb().
Sets the contents pointed to by r, g, b, and a, to the red, green, blue, and alpha-channel (transparency) components of the color's RGB value.
These components can be retrieved individually using the redF(), greenF(), blueF() and alphaF() functions.
Definition at line 887 of file qcolor.cpp.
Referenced by getRgbF().
qreal QColor::greenF | ( | ) | const |
Returns the green color component of this color.
Definition at line 1241 of file qcolor.cpp.
Referenced by QGLPixmapGLPaintDevice::beginPaint(), QGLWidgetGLPaintDevice::beginPaint(), QVGPaintEngine::clearRect(), QVGPixmapColorizeFilter::draw(), QGL2PaintEngineExPrivate::drawCachedGlyphs(), QMacStyle::drawComplexControl(), QMacStyle::drawControl(), QVGCompositionHelper::fillBackground(), QVGPaintEngine::fillRegion(), greenF(), operator<<(), qt_premultiplyColor(), QInternalMimeData::renderDataHelper(), QGLShaderProgram::setAttributeValue(), setBlueF(), QPSPrintEngine::setBrush(), QPdfEngine::setBrush(), QVGPaintEnginePrivate::setBrush(), setRedF(), QGLPixmapDropShadowFilter::setUniforms(), QGLShaderProgram::setUniformValue(), QVGPaintEnginePrivate::setupColorRamp(), and QDeclarativeEnginePrivate::tint().
int QColor::hslHue | ( | ) | const |
Returns the hue color component of this color.
Definition at line 1433 of file qcolor.cpp.
Referenced by hslHue().
qreal QColor::hslHueF | ( | ) | const |
Returns the hue color component of this color.
Definition at line 1485 of file qcolor.cpp.
Referenced by hslHueF(), and operator<<().
int QColor::hslSaturation | ( | ) | const |
Returns the saturation color component of this color.
Definition at line 1451 of file qcolor.cpp.
Referenced by hslSaturation().
qreal QColor::hslSaturationF | ( | ) | const |
Returns the saturation color component of this color.
Definition at line 1502 of file qcolor.cpp.
Referenced by hslSaturationF(), and operator<<().
int QColor::hsvHue | ( | ) | const |
Returns the hue color component of this color.
Definition at line 1311 of file qcolor.cpp.
Referenced by setBlueF().
qreal QColor::hsvHueF | ( | ) | const |
Returns the hue color component of this color.
Definition at line 1377 of file qcolor.cpp.
Referenced by hueF().
int QColor::hsvSaturation | ( | ) | const |
Returns the saturation color component of this color.
Definition at line 1338 of file qcolor.cpp.
Referenced by hsvHue().
qreal QColor::hsvSaturationF | ( | ) | const |
Returns the saturation color component of this color.
Definition at line 1403 of file qcolor.cpp.
Referenced by saturationF().
int QColor::hue | ( | ) | const |
Referenced by setBlueF(), toHsl(), and toHsv().
qreal QColor::hueF | ( | ) | const |
Returns the hue color component of this color.
The color is implicitly converted to HSV.
Definition at line 1366 of file qcolor.cpp.
Referenced by hsvHueF(), and operator<<().
|
private |
Marks the color as invalid and sets all components to zero (alpha is set to fully opaque for compatibility with Qt 3).
Definition at line 2563 of file qcolor.cpp.
Referenced by operator>>(), QColor(), setColorFromString(), setHsl(), setHsv(), setRgb(), and setRgbF().
|
inline |
Returns true if the color is valid; otherwise returns false.
Definition at line 295 of file qcolor.h.
Referenced by QTextHtmlParser::applyAttributes(), QDeclarativeStringConverters::colorFromString(), QDirectFBScreen::connect(), QDeclarativeTextLayout::draw(), QCommonStyle::drawComplexControl(), QWindowsCEStyle::drawComplexControl(), QWindowsMobileStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QCommonStyle::drawPrimitive(), QWindowsMobileStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QPainter::drawStaticText(), drawTextItemDecoration(), QColorWell::dropEvent(), QColorShowLabel::dropEvent(), QDirectFBPaintEngine::fillRect(), QColorDialog::getRgba(), hash(), QGLOverlayWidget::initializeGL(), QTabBar::initStyleOption(), operator<<(), QCss::Parser::parseHexColor(), resolveColor(), QPainter::setPen(), toCmyk(), toHsl(), toHsv(), and toRgb().
|
static |
Returns true if the name is a valid color name and can be used to construct a valid QColor object, otherwise returns false.
It uses the same algorithm used in setNamedColor().
Definition at line 579 of file qcolor.cpp.
QColor QColor::light | ( | int | factor = 150 | ) | const |
Use lighter(factor) instead.
Definition at line 2391 of file qcolor.cpp.
Referenced by QWindowsStyle::drawComplexControl(), QWindowsCEStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsStyle::drawControl(), lighter(), and qt_set_windows_color_resources().
|
inline |
Returns a lighter (or darker) color, but does not change this object.
If the factor is greater than 100, this functions returns a lighter color. Setting factor to 150 returns a color that is 50% brighter. If the factor is less than 100, the return color is darker, but we recommend using the darker() function for this purpose. If the factor is 0 or negative, the return value is unspecified.
The function converts the current RGB color to HSV, multiplies the value (V) component by factor and converts the color back to RGB.
Definition at line 298 of file qcolor.h.
Referenced by QRenderRule::configurePalette(), dark(), QPlastiqueStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QWindowsMobileStyle::drawControl(), QCleanlooksStyle::drawControl(), QGtkStyle::drawControl(), QMacStyle::drawControl(), QStyleHelper::drawDial(), QPlastiqueStyle::drawPrimitive(), QCleanlooksStyle::drawPrimitive(), QDeclarativeEnginePrivate::lighter(), QDecorationWindows::paint(), QDecorationWindows::paintButton(), QCleanlooksStyle::polish(), qBrushLight(), qDrawEdge(), qDrawRoundedCorners(), qt_cleanlooks_draw_buttongradient(), qt_plastique_drawFrame(), qt_plastique_drawShadedPanel(), qt_set_windows_color_resources(), QCleanlooksStyle::standardPalette(), QCDEStyle::standardPalette(), QGtkStyle::standardPalette(), QStyle::standardPalette(), QMotifStyle::standardPalette(), QWindowsMobileStyle::standardPixmap(), and QScriptEdit::updateExtraSelections().
int QColor::lightness | ( | ) | const |
Referenced by hslSaturation(), and toHsl().
qreal QColor::lightnessF | ( | ) | const |
Returns the lightness color component of this color.
Definition at line 1519 of file qcolor.cpp.
Referenced by lightnessF(), and operator<<().
int QColor::magenta | ( | ) | const |
Referenced by lightnessF().
qreal QColor::magentaF | ( | ) | const |
Returns the magenta color component of this color.
Definition at line 1598 of file qcolor.cpp.
Referenced by magentaF(), and operator<<().
QString QColor::name | ( | ) | const |
Returns the name of the color in the format "#RRGGBB"; i.e.
a "#" character followed by three two-digit hexadecimal numbers.
Definition at line 529 of file qcolor.cpp.
Referenced by QmlJSDebugger::ToolBarColorBox::copyColorToClipboard(), QTextHtmlExporter::emitBackgroundAttribute(), QTextHtmlExporter::emitCharFormatStyle(), QTextHtmlExporter::emitFrameStyle(), generateWavyPixmap(), QmlJSDebugger::ToolBarColorBox::mouseMoveEvent(), QTextOdfWriter::writeBlockFormat(), and QTextOdfWriter::writeCharacterFormat().
QColor::operator QVariant | ( | ) | const |
Returns the color as a QVariant.
Definition at line 2521 of file qcolor.cpp.
bool QColor::operator!= | ( | const QColor & | c | ) | const |
Returns true if this color has a different RGB and alpha values from color; otherwise returns false.
Definition at line 2514 of file qcolor.cpp.
Assigns a copy of color to this color, and returns a reference to it.
Definition at line 2464 of file qcolor.cpp.
Referenced by operator=().
QColor & QColor::operator= | ( | Qt::GlobalColor | color | ) |
Assigns a copy of color and returns a reference to this color.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 2477 of file qcolor.cpp.
bool QColor::operator== | ( | const QColor & | c | ) | const |
Returns true if this color has the same RGB and alpha values as color; otherwise returns false.
Definition at line 2486 of file qcolor.cpp.
Referenced by operator!=().
int QColor::red | ( | ) | const |
Referenced by name(), setAlphaF(), setBlue(), and setGreen().
qreal QColor::redF | ( | ) | const |
Returns the red color component of this color.
Definition at line 1213 of file qcolor.cpp.
Referenced by QGLPixmapGLPaintDevice::beginPaint(), QGLWidgetGLPaintDevice::beginPaint(), QVGPaintEngine::clearRect(), QVGPixmapColorizeFilter::draw(), QGL2PaintEngineExPrivate::drawCachedGlyphs(), QMacStyle::drawComplexControl(), QMacStyle::drawControl(), QVGCompositionHelper::fillBackground(), QVGPaintEngine::fillRegion(), operator<<(), qt_premultiplyColor(), redF(), QInternalMimeData::renderDataHelper(), QGLShaderProgram::setAttributeValue(), setBlueF(), QPSPrintEngine::setBrush(), QPdfEngine::setBrush(), QVGPaintEnginePrivate::setBrush(), setGreenF(), QGLPixmapDropShadowFilter::setUniforms(), QGLShaderProgram::setUniformValue(), QVGPaintEnginePrivate::setupColorRamp(), and QDeclarativeEnginePrivate::tint().
QColor::rgb | ( | ) | const |
Returns the RGB value of the color.
Use getRgb() instead.
The alpha value is opaque.
Definition at line 1051 of file qcolor.cpp.
Referenced by QGLGlyphCache::allocTexture(), QGLContext::choosePixelFormat(), QX11PixmapData::createBitmapFromImage(), darkenPixmap(), QWindowsMobileStylePrivate::drawScrollbarGroove(), QWin32PrintEngine::drawTextItem(), QColorWell::dropEvent(), QX11PixmapData::fill(), QBitmap::fromImage(), QWindowsMobileStyle::generatedIconPixmap(), QColorShower::hsvEd(), makeBitmapCompliantIfNeeded(), operator<<(), QColorLuminancePicker::paintEvent(), QmlJSDebugger::ColorPickerTool::pickColor(), QCleanlooksStyle::polish(), qt_transparent_pixel(), QColorPicker::resizeEvent(), rgb(), QColorDialogPrivate::selectColor(), QPainter::setBackground(), QPainter::setBrush(), setColorFromString(), QColorDialog::setCurrentColor(), QGLColormap::setEntry(), QColorShower::setHsv(), QPainter::setPen(), QAhiScreen::solidFill(), QMotifStyle::standardPixmap(), QCommonStyle::styleHint(), QWindowsVistaStyle::styleHint(), QCleanlooksStyle::styleHint(), QX11PixmapData::toImage(), and QX11PaintEngine::updatePen().
QRgb QColor::rgba | ( | ) | const |
Returns the RGB value of the color, including its alpha.
For an invalid color, the alpha value of the returned color is unspecified.
Definition at line 1019 of file qcolor.cpp.
Referenced by QPdfEnginePrivate::addImage(), QGLPixmapData::bind(), QRasterBuffer::colorizeBitmap(), colorizeBitmap(), QImageData::create(), QPixmap::createMaskFromColor(), QPlastiqueStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QWindowsMobileStyle::drawPrimitive(), QPlastiqueStyle::drawPrimitive(), QCleanlooksStyle::drawPrimitive(), QGtkStyle::drawPrimitive(), QBlittablePixmapData::fill(), QMacPixmapData::fill(), QRasterPixmapData::fill(), QX11PixmapData::fill(), QVGPixmapData::fill(), QGLPixmapData::fill(), QImage::fill(), QGLPixmapData::fillImage(), QWindowsMobileStyle::generatedIconPixmap(), QDeclarativeCompiler::genLiteralAssignment(), QColorDialog::getRgba(), hash(), QGLPixmapData::paintEngine(), QColormap::pixel(), qBrushDark(), qBrushLight(), qBrushSetAlphaF(), QRenderRule::QRenderRule(), qt_conv16ToRgb(), qt_plastique_draw_gradient(), qt_plastique_draw_handle(), QSvgIOHandler::read(), rgba(), QPSPrintEngine::setBrush(), QPdfEngine::setBrush(), QSpanData::setup(), QAhiScreen::solidFill(), solidFill_template(), QWindowsMobileStyle::standardPixmap(), QGtkStyle::standardPixmap(), QCommonStyle::styleHint(), QStyleSheetStyle::styleHint(), QX11PaintEngine::updateBrush(), and QX11PaintEngine::updatePen().
int QColor::saturation | ( | ) | const |
Referenced by hsvHue().
qreal QColor::saturationF | ( | ) | const |
Returns the saturation color component of this color.
The color is implicitly converted to HSV.
Definition at line 1392 of file qcolor.cpp.
Referenced by hsvSaturationF(), and operator<<().
|
static |
Allow setNamedColor() to look up colors in the X11 color database if enabled.
By default, setNamedColor() does not look up colors in the X11 color database.
Definition at line 2549 of file qcolor.cpp.
Referenced by qt_set_x11_resources().
void QColor::setAlpha | ( | int | alpha | ) |
Sets the alpha of this color to alpha.
Integer alpha is specified in the range 0-255.
Definition at line 1094 of file qcolor.cpp.
Referenced by QTextLine::draw(), QCleanlooksStyle::drawComplexControl(), QGtkStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QMacStyle::drawControl(), QStyleHelper::drawDial(), QPlastiqueStyle::drawPrimitive(), QCleanlooksStyle::drawPrimitive(), QWindowsMobileStyle::generatedIconPixmap(), QPagePreview::paintEvent(), QLineEdit::paintEvent(), qt_plastique_draw_handle(), QGtkStyle::standardPixmap(), QX11PaintEngine::updateBrush(), and QX11PaintEngine::updatePen().
void QColor::setAlphaF | ( | qreal | alpha | ) |
Sets the alpha of this color to alpha.
qreal alpha is specified in the range 0.0-1.0.
Definition at line 1117 of file qcolor.cpp.
Referenced by constructColor(), QMacStyle::drawControl(), QStyleHelper::drawDial(), QMacStyle::drawPrimitive(), QWidgetPrivate::drawWidget(), QCommonStyle::generatedIconPixmap(), make_widget_eventUPP(), qBrushSetAlphaF(), qt_premultiplyColor(), QItemDelegate::selected(), and QVGPaintEnginePrivate::setBrush().
void QColor::setBlue | ( | int | blue | ) |
Sets the blue color component of this color to blue.
Integer components are specified in the range 0-255.
Definition at line 1199 of file qcolor.cpp.
Referenced by QCommandLinkButtonPrivate::mergedColors(), and mergedColors().
void QColor::setBlueF | ( | qreal | blue | ) |
Sets the blue color component of this color to blue.
Float components are specified in the range 0.0-1.0.
Definition at line 1282 of file qcolor.cpp.
Referenced by qt_premultiplyColor().
void QColor::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, i.e.
transparency).
All the values must be in the range 0-255.
Definition at line 2243 of file qcolor.cpp.
Referenced by QColor().
Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
e. transparency).
All the values must be in the range 0.0-1.0. \sa getCmykF() setCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}
Definition at line 2276 of file qcolor.cpp.
Referenced by qcolorFromCGColor().
|
private |
Definition at line 584 of file qcolor.cpp.
Referenced by setNamedColor().
void QColor::setGreen | ( | int | green | ) |
Sets the green color component of this color to green.
Integer components are specified in the range 0-255.
Definition at line 1170 of file qcolor.cpp.
Referenced by QCommandLinkButtonPrivate::mergedColors(), and mergedColors().
void QColor::setGreenF | ( | qreal | green | ) |
Sets the green color component of this color to green.
Float components are specified in the range 0.0-1.0.
Definition at line 1255 of file qcolor.cpp.
Referenced by qt_premultiplyColor().
void QColor::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 component of the HSL color.
The saturation, value and alpha-channel values must be in the range 0-255, and the hue value must be greater than -1.
Definition at line 861 of file qcolor.cpp.
Referenced by QColor().
Sets a HSL color lightness; h is the hue, s is the saturation, l is the lightness and a is the alpha component of the HSL color.
All the values must be in the range 0.0-1.0.
Definition at line 829 of file qcolor.cpp.
void QColor::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 component of the HSV color.
The saturation, value and alpha-channel values must be in the range 0-255, and the hue value must be greater than -1.
Definition at line 734 of file qcolor.cpp.
Referenced by darkenPixmap(), QCleanlooksStyle::drawComplexControl(), QGtkStyle::drawComplexControl(), QCleanlooksStyle::drawControl(), QStyleHelper::drawDial(), QCleanlooksStyle::drawPrimitive(), QColorShower::hsvEd(), QColorLuminancePicker::paintEvent(), QColor(), qt_cleanlooks_draw_mdibutton(), QColorPicker::resizeEvent(), QColorShower::setHsv(), and QGtkStyle::standardPalette().
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha component of the HSV color.
All the values must be in the range 0.0-1.0.
Definition at line 706 of file qcolor.cpp.
Referenced by QMacStyle::drawControl().
void QColor::setNamedColor | ( | const QString & | name | ) |
Sets the RGB value of this QColor to name, which may be in one of these formats:
transparent
- representing the absence of a color. XParseColor()
for information about valid X11 color names. The color is invalid if name cannot be parsed.
Definition at line 560 of file qcolor.cpp.
Referenced by QTextHtmlParser::applyAttributes(), and QCss::Parser::parseHexColor().
void QColor::setRed | ( | int | red | ) |
Sets the red color component of this color to red.
Integer components are specified in the range 0-255.
Definition at line 1143 of file qcolor.cpp.
Referenced by QCommandLinkButtonPrivate::mergedColors(), and mergedColors().
void QColor::setRedF | ( | qreal | red | ) |
Sets the red color component of this color to red.
Float components are specified in the range 0.0-1.0.
Definition at line 1227 of file qcolor.cpp.
Referenced by qt_premultiplyColor().
void QColor::setRgb | ( | int | r, |
int | g, | ||
int | b, | ||
int | a = 255 |
||
) |
Sets the RGB value to r, g, b and the alpha value to a.
All the values must be in the range 0-255.
Definition at line 980 of file qcolor.cpp.
Referenced by QmlJSDebugger::ColorPickerTool::ColorPickerTool(), operator>>(), qBrushDark(), qBrushLight(), qBrushSetAlphaF(), QColor(), resolveColor(), rgb2hsv(), setBlue(), setColorFromString(), setGreen(), and setRed().
void QColor::setRgb | ( | QRgb | rgb | ) |
Sets the RGB value to rgb.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The alpha value is set to opaque.
Definition at line 1066 of file qcolor.cpp.
void QColor::setRgba | ( | QRgb | rgba | ) |
Use setRgb() instead.
Sets the RGB value to rgba, including its alpha.
Definition at line 1031 of file qcolor.cpp.
Referenced by setColorFromString(), and QColorShower::updateQColor().
Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency).
All values must be in the range 0.0-1.0.
Definition at line 954 of file qcolor.cpp.
Referenced by qcolorFromCGColor(), QInternalMimeData::retrieveData(), setBlueF(), setGreenF(), setRedF(), and QDeclarativeEnginePrivate::tint().
|
inline |
Returns how the color was specified.
Definition at line 88 of file qcolor.h.
Referenced by operator<<(), and QColorDialogPrivate::setCocoaPanelColor().
QColor QColor::toCmyk | ( | ) | const |
Creates and returns a CMYK QColor based on this color.
Definition at line 1891 of file qcolor.cpp.
Referenced by blackF(), convertTo(), cyanF(), getCmyk(), getCmykF(), lightnessF(), magentaF(), toCmyk(), and yellowF().
QColor QColor::toHsl | ( | ) | const |
Creates and returns an HSL QColor based on this color.
Definition at line 1834 of file qcolor.cpp.
Referenced by convertTo(), getHsl(), getHslF(), hslHue(), hslHueF(), hslSaturation(), hslSaturationF(), lightnessF(), and toHsl().
QColor QColor::toHsv | ( | ) | const |
Creates and returns an HSV QColor based on this color.
Definition at line 1783 of file qcolor.cpp.
Referenced by convertTo(), dark(), getHsv(), getHsvF(), hsvHue(), hsvHueF(), hsvSaturation(), hsvSaturationF(), light(), toHsv(), and valueF().
QColor QColor::toRgb | ( | ) | const |
Create and returns an RGB QColor based on this color.
Definition at line 1636 of file qcolor.cpp.
Referenced by blueF(), convertTo(), getRgb(), getRgbF(), greenF(), redF(), rgb(), rgba(), setAlphaF(), setGreen(), setRed(), toCmyk(), toHsl(), and toHsv().
int QColor::value | ( | ) | const |
Referenced by hsvSaturation().
qreal QColor::valueF | ( | ) | const |
Returns the value color component of this color.
Definition at line 1416 of file qcolor.cpp.
Referenced by operator<<(), and valueF().
int QColor::yellow | ( | ) | const |
Referenced by lightnessF().
qreal QColor::yellowF | ( | ) | const |
Returns the yellow color component of this color.
Definition at line 1611 of file qcolor.cpp.
Referenced by operator<<(), and yellowF().
|
friend |
Writes the color to the stream.
Definition at line 2638 of file qcolor.cpp.
|
friend |
Reads the color from the stream.
Definition at line 2677 of file qcolor.cpp.
|
related |
Returns the alpha component of the ARGB quadruplet rgba.
Definition at line 66 of file qrgb.h.
Referenced by destStoreARGB32(), fromRgba(), QColor(), setRgba(), and sourceOver().
|
related |
Returns the blue component of the ARGB quadruplet rgb.
Definition at line 63 of file qrgb.h.
Referenced by destStoreARGB32(), findNearestColor(), fromRgb(), fromRgba(), QColor(), qGray(), qIsGray(), qt_convRgbTo16(), qt_write_dib(), setRgb(), setRgba(), and write_pbm_image().
|
related |
Returns a gray value (0 to 255) from the (r, g, b) triplet.
The gray value is calculated using the formula (r * 11 + g * 16 + b * 5)/32.
Definition at line 75 of file qrgb.h.
Referenced by destStoreMono(), destStoreMonoLsb(), qGray(), read_dib_body(), write_pbm_image(), and write_xbm_image().
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a gray value (0 to 255) from the given ARGB quadruplet rgb.
The gray value is calculated using the formula (R * 11 + G * 16 + B * 5)/32; the alpha-channel is ignored.
|
related |
Returns the green component of the ARGB quadruplet rgb.
Definition at line 60 of file qrgb.h.
Referenced by destStoreARGB32(), findNearestColor(), fromRgb(), fromRgba(), QColor(), qGray(), qIsGray(), qt_convRgbTo16(), qt_write_dib(), setRgb(), setRgba(), and write_pbm_image().
|
related |
Returns the red component of the ARGB quadruplet rgb.
Definition at line 57 of file qrgb.h.
Referenced by destStoreARGB32(), findNearestColor(), fromRgb(), fromRgba(), QColor(), qGray(), qIsGray(), qt_convRgbTo16(), qt_write_dib(), setRgb(), setRgba(), and write_pbm_image().
|
related |
Returns the ARGB quadruplet (255, {r}, {g}, {b}).
Definition at line 69 of file qrgb.h.
Referenced by convert_rgb888_to_rgb32_C(), qsvg_get_hex_rgb(), qt_conv16ToRgb(), qt_get_hex_rgb(), read_dib_body(), read_pbm_body(), read_xbm_body(), and rgb().
|
related |
An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
The type also holds a value for the alpha-channel. The default alpha channel is ff
, i.e opaque. For more information, see the Alpha-Blended Drawing section.
|
related |
struct { ... } QColor::acmyk |
Referenced by fromCmyk(), fromCmykF(), and toCmyk().
struct { ... } QColor::ahsl |
Referenced by fromHsl(), fromHslF(), operator==(), and toHsl().
struct { ... } QColor::ahsv |
Referenced by dark(), fromHsv(), fromHsvF(), light(), operator==(), and toHsv().
int QColor::alpha |
Returns the alpha color component of this color.
Definition at line 242 of file qcolor.h.
Referenced by _q_interpolate(), QPdfEnginePrivate::addBrushPattern(), QDirectFbBlitter::alphaFillRect(), QSvgAnimateColor::apply(), cgColorForQColor(), clearRect(), QDirectFBScreen::connect(), QBlittablePixmapData::fill(), QMacPixmapData::fill(), QDirectFBPixmapData::fill(), QRasterPixmapData::fill(), QX11PixmapData::fill(), QPixmap::fill(), QGLPixmapData::fill(), QX11PaintEnginePrivate::fillPolygon_dev(), QBlitterPaintEngine::fillRect(), QVGPaintEngine::fillRect(), QBrush::isOpaque(), QX11Data::preMultiply(), QDirectFBPaintEnginePrivate::prepareForDraw(), qt_mix_colors(), QDeclarativePen::setColor(), QColorDialog::setCurrentColor(), QOpenGLPaintEnginePrivate::setGLBrush(), QOpenGLPaintEnginePrivate::setGLPen(), QDeclarativePen::setWidth(), QGtkStyle::standardPalette(), QDeclarativeEnginePrivate::tint(), QX11PaintEngine::updateBrush(), QBlitterPaintEnginePrivate::updateBrushState(), QPainterPrivate::updateEmulationSpecifier(), and QX11PaintEngine::updatePen().
struct { ... } QColor::argb |
Referenced by fromRgb(), fromRgbF(), operator<<(), operator=(), operator==(), operator>>(), QColor(), and toRgb().
int QColor::black |
Returns the black color component of this color.
Definition at line 260 of file qcolor.h.
Referenced by lightnessF().
int QColor::blue |
Returns the blue color component of this color.
Definition at line 245 of file qcolor.h.
Referenced by _q_interpolate(), QDirectFbBlitter::alphaFillRect(), QSvgAnimateColor::apply(), QAccessibleTextWidget::attributes(), cgColorForQColor(), clearRect(), QDirectFBScreen::connect(), QWindowsXPStyle::drawControl(), QWindowsMobileStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QDirectFBPixmapData::fill(), QWin32PrintEnginePrivate::fillPath_dev(), fromQColor(), QCommonStyle::generatedIconPixmap(), QCommandLinkButtonPrivate::mergedColors(), mergedColors(), QStaticTextPrivate::paintText(), QX11Data::preMultiply(), QDirectFBPaintEnginePrivate::prepareForDraw(), QColorToOLEColor(), qt_graphicsItem_highlightSelected(), qt_mac_display_change_callbk(), qt_mix_colors(), qt_set_windows_color_resources(), qt_transparent_pixel(), QMngHandlerPrivate::setBackgroundColor(), QCoreGraphicsPaintEnginePrivate::setFillBrush(), QOpenGLPaintEnginePrivate::setGLBrush(), QOpenGLPaintEnginePrivate::setGLPen(), setGreen(), QGtkStyle::standardPalette(), QWin32PrintEnginePrivate::strokePath_dev(), and translate_color().
|
private |
Definition at line 239 of file qcolor.h.
Referenced by blackF(), blueF(), convertTo(), cyanF(), dark(), fromCmyk(), fromCmykF(), fromHsl(), fromHslF(), fromHsv(), fromHsvF(), fromRgb(), fromRgbF(), getCmyk(), getCmykF(), getHsl(), getHslF(), getHsv(), getHsvF(), getRgb(), getRgbF(), greenF(), hslHue(), hslHueF(), hslSaturation(), hslSaturationF(), hsvHue(), hsvHueF(), hsvSaturation(), hsvSaturationF(), invalidate(), isValid(), light(), lightnessF(), magentaF(), operator<<(), operator=(), operator==(), operator>>(), QColor(), redF(), rgb(), rgba(), setAlphaF(), setBlue(), setBlueF(), setCmyk(), setCmykF(), setGreen(), setGreenF(), setHsl(), setHslF(), setHsv(), setHsvF(), setRed(), setRedF(), setRgb(), setRgba(), setRgbF(), toCmyk(), toHsl(), toHsv(), toRgb(), valueF(), and yellowF().
union { ... } QColor::ct |
Referenced by alphaF(), blackF(), blueF(), cyanF(), dark(), fromCmyk(), fromCmykF(), fromHsl(), fromHslF(), fromHsv(), fromHsvF(), fromRgb(), fromRgbF(), getCmyk(), getCmykF(), getHsl(), getHslF(), getHsv(), getHsvF(), getRgb(), getRgbF(), greenF(), hslHue(), hslHueF(), hslSaturation(), hslSaturationF(), hsvHue(), hsvHueF(), hsvSaturation(), hsvSaturationF(), invalidate(), light(), lightnessF(), magentaF(), operator<<(), operator=(), operator==(), operator>>(), QColor(), redF(), rgb(), rgba(), setAlpha(), setAlphaF(), setBlue(), setBlueF(), setCmyk(), setCmykF(), setGreen(), setGreenF(), setHsl(), setHslF(), setHsv(), setHsvF(), setRed(), setRedF(), setRgb(), setRgba(), setRgbF(), toCmyk(), toHsl(), toHsv(), toRgb(), valueF(), and yellowF().
int QColor::cyan |
Returns the cyan color component of this color.
Definition at line 257 of file qcolor.h.
Referenced by lightnessF().
int QColor::green |
Returns the green color component of this color.
Definition at line 244 of file qcolor.h.
Referenced by _q_interpolate(), QDirectFbBlitter::alphaFillRect(), QSvgAnimateColor::apply(), QAccessibleTextWidget::attributes(), cgColorForQColor(), clearRect(), QDirectFBScreen::connect(), QWindowsXPStyle::drawControl(), QWindowsMobileStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QDirectFBPixmapData::fill(), QWin32PrintEnginePrivate::fillPath_dev(), fromQColor(), QCommonStyle::generatedIconPixmap(), QCommandLinkButtonPrivate::mergedColors(), mergedColors(), QStaticTextPrivate::paintText(), QX11Data::preMultiply(), QDirectFBPaintEnginePrivate::prepareForDraw(), QColorToOLEColor(), qt_graphicsItem_highlightSelected(), qt_mac_display_change_callbk(), qt_mix_colors(), qt_set_windows_color_resources(), qt_transparent_pixel(), QMngHandlerPrivate::setBackgroundColor(), QCoreGraphicsPaintEnginePrivate::setFillBrush(), QOpenGLPaintEnginePrivate::setGLBrush(), QOpenGLPaintEnginePrivate::setGLPen(), setRed(), QGtkStyle::standardPalette(), QWin32PrintEnginePrivate::strokePath_dev(), and translate_color().
int QColor::hue |
Returns the hue color component of this color.
The color is implicitly converted to HSV.
Definition at line 250 of file qcolor.h.
Referenced by QCleanlooksStyle::drawComplexControl(), QGtkStyle::drawComplexControl(), QCleanlooksStyle::drawControl(), QStyleHelper::drawDial(), QCleanlooksStyle::drawPrimitive(), hsvHue(), qt_cleanlooks_draw_mdibutton(), and QGtkStyle::standardPalette().
int QColor::lightness |
Returns the lightness color component of this color.
Definition at line 266 of file qcolor.h.
Referenced by hslSaturation().
int QColor::magenta |
Returns the magenta color component of this color.
Definition at line 258 of file qcolor.h.
Referenced by lightnessF().
int QColor::red |
Returns the red color component of this color.
Definition at line 243 of file qcolor.h.
Referenced by _q_interpolate(), QDirectFbBlitter::alphaFillRect(), QSvgAnimateColor::apply(), QAccessibleTextWidget::attributes(), cgColorForQColor(), clearRect(), QDirectFBScreen::connect(), QWindowsXPStyle::drawControl(), QWindowsMobileStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QDirectFBPixmapData::fill(), QWin32PrintEnginePrivate::fillPath_dev(), fromQColor(), QCommonStyle::generatedIconPixmap(), QCommandLinkButtonPrivate::mergedColors(), mergedColors(), QStaticTextPrivate::paintText(), QX11Data::preMultiply(), QDirectFBPaintEnginePrivate::prepareForDraw(), QColorToOLEColor(), qt_graphicsItem_highlightSelected(), qt_mac_display_change_callbk(), qt_mix_colors(), qt_set_windows_color_resources(), qt_transparent_pixel(), QLinuxFbScreen::set(), setAlphaF(), QMngHandlerPrivate::setBackgroundColor(), QCoreGraphicsPaintEnginePrivate::setFillBrush(), QOpenGLPaintEnginePrivate::setGLBrush(), QOpenGLPaintEnginePrivate::setGLPen(), QGtkStyle::standardPalette(), QWin32PrintEnginePrivate::strokePath_dev(), and translate_color().
int QColor::saturation |
Returns the saturation color component of this color.
The color is implicitly converted to HSV.
Definition at line 251 of file qcolor.h.
Referenced by QCleanlooksStyle::drawComplexControl(), QGtkStyle::drawComplexControl(), QCleanlooksStyle::drawControl(), QStyleHelper::drawDial(), QCleanlooksStyle::drawPrimitive(), hsvSaturation(), and qt_cleanlooks_draw_mdibutton().
int QColor::value |
Returns the value color component of this color.
Definition at line 252 of file qcolor.h.
Referenced by QCleanlooksStyle::drawComplexControl(), QGtkStyle::drawComplexControl(), QCleanlooksStyle::drawControl(), QStyleHelper::drawDial(), QCleanlooksStyle::drawPrimitive(), hsvSaturation(), qBrushSetAlphaF(), qt_cleanlooks_draw_mdibutton(), and QGtkStyle::standardPalette().
int QColor::yellow |
Returns the yellow color component of this color.
Definition at line 259 of file qcolor.h.
Referenced by lightnessF().