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.

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-BlendedDrawing 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.

PySide.QtGui.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.

While the integer based functions take values in the range 0-255 (except PySide.QtGui.QColor.hue() which must have values within the range 0-359), the floating point functions accept values in the range 0.0 - 1.0.

PySide.QtGui.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:

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. PySide.QtGui.QColor also recognizes a variety of color names; the static PySide.QtGui.QColor.colorNames() function returns a PySide.QtCore.QStringList color names that PySide.QtGui.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-blendeddrawing .

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-blendeddrawing .

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 PySide.QtGui.QColor.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.

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 PySide.QtGui.QColor.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.

A name from the list of colors defined in the list of SVG color keyword names provided by the World Wide Web Consortium; for example, “steelblue” or “gainsboro”. These color names work on all platforms. Note that these color names are not the same as defined by the Qt.GlobalColor enums, e.g. “green” and Qt.green does not refer to the same color.