

#Color brown in 255 255 255 code#
The code above produces the following output: The alpha channel of a color specifies the transparency effect, 0 represents a fully transparent color, while 255 represents a fully opaque color. QColor also support alpha-blended outlining and filling. 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. 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. QColor supports floating point precision and provides floating point versions of all the color components functions, e.g. The QColormap class maps the color to the hardware.įor more information about painting in general, see the Paint System documentation. QColor is platform and device independent. 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. 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. Note that it also can hold a value for the alpha-channel (for more information, see the Alpha-Blended Drawing section). There are several related non-members: QRgb is a typdef for an unsigned int representing the RGB value triplet (r, g, b). Using the RGB color model, the color components can in addition be accessed with rgb(). The values of the color components can also be retrieved in one go using the getRgb(), getHsv() and getCmyk() functions. The color components can be retrieved individually, e.g with red(), hue() and cyan(). For performance reasons, QColor mostly disregards illegal colors, and for that reason, the result of using an invalid color is undefined. For example, a RGB color with RGB values out of range is illegal. The isValid() function indicates whether a QColor is legal at all.

To get a lighter or darker color use the lighter() and darker() functions respectively. Colors can also be set using setRgb(), setHsv() and setCmyk(). The name() function returns the name of the color in the format "#RRGGBB". The color names are taken from the SVG 1.0 color names. The spec() function tells how the color was specified.Ī color can be set by passing an RGB string (such as "#112233"), or an ARGB string (such as "#ff112233") or a color name (such as "blue"), to the setNamedColor() function. 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. In addition the static fromRgb(), fromHsv() and fromCmyk() functions create colors from the specified values. These functions return a copy of the color using the desired format. To create a QColor based on either HSV or CMYK values, use the toHsv() and toCmyk() functions respectively. The QColor constructor creates the color based on RGB values. SetRgbF(qreal r, qreal g, qreal b, qreal a = 1.0) SetHsvF(qreal h, qreal s, qreal v, qreal a = 1.0) SetHslF(qreal h, qreal s, qreal l, qreal a = 1.0) SetCmykF(qreal c, qreal m, qreal y, qreal k, qreal a = 1.0) SetCmyk(int c, int m, int y, int k, int a = 255) GetRgbF(qreal * r, qreal * g, qreal * b, qreal * a = nullptr) const

GetRgb(int * r, int * g, int * b, int * a = nullptr) const GetHsvF(qreal * h, qreal * s, qreal * v, qreal * a = nullptr) const GetHsv(int * h, int * s, int * v, int * a = nullptr) const GetHslF(qreal * h, qreal * s, qreal * l, qreal * a = nullptr) const GetHsl(int * h, int * s, int * l, int * a = nullptr) const GetCmykF(qreal * c, qreal * m, qreal * y, qreal * k, qreal * a = nullptr) const GetCmyk(int * c, int * m, int * y, int * k, int * a = nullptr) const
