QtBase  v6.3.1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | Related Functions | List of all members
QColor Class Reference

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 , ExtendedRgb
}
 
enum  NameFormat { HexRgb , HexArgb }
 

Public Member Functions

constexpr QColor () noexcept
 
 QColor (Qt::GlobalColor color) noexcept
 
constexpr QColor (int r, int g, int b, int a=255) noexcept
 
 QColor (QRgb rgb) noexcept
 
 QColor (QRgba64 rgba64) noexcept
 
 QColor (const QString &name)
 
 QColor (QStringView name)
 
 QColor (const char *aname)
 
 QColor (QLatin1String name)
 
 QColor (Spec spec) noexcept
 
QColoroperator= (Qt::GlobalColor color) noexcept
 
bool isValid () const noexcept
 
QString name (NameFormat format=HexRgb) const
 
void setNamedColor (const QString &name)
 
void setNamedColor (QStringView name)
 
void setNamedColor (QLatin1String name)
 
Spec spec () const noexcept
 
int alpha () const noexcept
 
void setAlpha (int alpha)
 
float alphaF () const noexcept
 
void setAlphaF (float alpha)
 
int red () const noexcept
 
int green () const noexcept
 
int blue () const noexcept
 
void setRed (int red)
 
void setGreen (int green)
 
void setBlue (int blue)
 
float redF () const noexcept
 
float greenF () const noexcept
 
float blueF () const noexcept
 
void setRedF (float red)
 
void setGreenF (float green)
 
void setBlueF (float blue)
 
void getRgb (int *r, int *g, int *b, int *a=nullptr) const
 
void setRgb (int r, int g, int b, int a=255)
 
void getRgbF (float *r, float *g, float *b, float *a=nullptr) const
 
void setRgbF (float r, float g, float b, float a=1.0)
 
QRgba64 rgba64 () const noexcept
 
void setRgba64 (QRgba64 rgba) noexcept
 
QRgb rgba () const noexcept
 
void setRgba (QRgb rgba) noexcept
 
QRgb rgb () const noexcept
 
void setRgb (QRgb rgb) noexcept
 
int hue () const noexcept
 
int saturation () const noexcept
 
int hsvHue () const noexcept
 
int hsvSaturation () const noexcept
 
int value () const noexcept
 
float hueF () const noexcept
 
float saturationF () const noexcept
 
float hsvHueF () const noexcept
 
float hsvSaturationF () const noexcept
 
float valueF () const noexcept
 
void getHsv (int *h, int *s, int *v, int *a=nullptr) const
 
void setHsv (int h, int s, int v, int a=255)
 
void getHsvF (float *h, float *s, float *v, float *a=nullptr) const
 
void setHsvF (float h, float s, float v, float a=1.0)
 
int cyan () const noexcept
 
int magenta () const noexcept
 
int yellow () const noexcept
 
int black () const noexcept
 
float cyanF () const noexcept
 
float magentaF () const noexcept
 
float yellowF () const noexcept
 
float blackF () const noexcept
 
void getCmyk (int *c, int *m, int *y, int *k, int *a=nullptr) const
 
void setCmyk (int c, int m, int y, int k, int a=255)
 
void getCmykF (float *c, float *m, float *y, float *k, float *a=nullptr) const
 
void setCmykF (float c, float m, float y, float k, float a=1.0)
 
int hslHue () const noexcept
 
int hslSaturation () const noexcept
 
int lightness () const noexcept
 
float hslHueF () const noexcept
 
float hslSaturationF () const noexcept
 
float lightnessF () const noexcept
 
void getHsl (int *h, int *s, int *l, int *a=nullptr) const
 
void setHsl (int h, int s, int l, int a=255)
 
void getHslF (float *h, float *s, float *l, float *a=nullptr) const
 
void setHslF (float h, float s, float l, float a=1.0)
 
QColor toRgb () const noexcept
 
QColor toHsv () const noexcept
 
QColor toCmyk () const noexcept
 
QColor toHsl () const noexcept
 
QColor toExtendedRgb () const noexcept
 
QColor convertTo (Spec colorSpec) const noexcept
 
QColor lighter (int f=150) const noexcept
 
QColor darker (int f=200) const noexcept
 
bool operator== (const QColor &c) const noexcept
 
bool operator!= (const QColor &c) const noexcept
 
 operator QVariant () const
 

Static Public Member Functions

static QStringList colorNames ()
 
static QColor fromRgb (QRgb rgb) noexcept
 
static QColor fromRgba (QRgb rgba) noexcept
 
static QColor fromRgb (int r, int g, int b, int a=255)
 
static QColor fromRgbF (float r, float g, float b, float a=1.0)
 
static QColor fromRgba64 (ushort r, ushort g, ushort b, ushort a=USHRT_MAX) noexcept
 
static QColor fromRgba64 (QRgba64 rgba) noexcept
 
static QColor fromHsv (int h, int s, int v, int a=255)
 
static QColor fromHsvF (float h, float s, float v, float a=1.0)
 
static QColor fromCmyk (int c, int m, int y, int k, int a=255)
 
static QColor fromCmykF (float c, float m, float y, float k, float a=1.0)
 
static QColor fromHsl (int h, int s, int l, int a=255)
 
static QColor fromHslF (float h, float s, float l, float a=1.0)
 
static bool isValidColor (const QString &name)
 
static bool isValidColor (QStringView) noexcept
 
static bool isValidColor (QLatin1String) noexcept
 

Friends

class QColormap
 
Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, const QColor &)
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &, QColor &)
 

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &stream, const QColor &color)
 
QDataStreamoperator>> (QDataStream &stream, QColor &color)
 
int qRed (QRgb rgb)
 
int qGreen (QRgb rgb)
 
int qBlue (QRgb rgb)
 
int qAlpha (QRgb rgba)
 
QRgb qRgb (int r, int g, int b)
 
QRgb qRgba (int r, int g, int b, int a)
 
int qGray (int r, int g, int b)
 
int qGray (QRgb rgb)
 
QRgb qPremultiply (QRgb rgb)
 
QRgb qUnpremultiply (QRgb rgb)
 
 QRgb
 

Detailed Description

The QColor class provides colors based on RGB, HSV or CMYK values.

\inmodule QtGui

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.

\table \header

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 an ARGB string (such as "#ff112233") 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 \l {QColor::Alpha-Blended Drawing}{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 \l{Paint System} documentation.

Definition at line 66 of file qcolor.h.

Member Enumeration Documentation

◆ NameFormat

How to format the output of the name() function

\value HexRgb #RRGGBB A "#" character followed by three two-digit hexadecimal numbers (i.e. {#RRGGBB}). \value HexArgb #AARRGGBB A "#" character followed by four two-digit hexadecimal numbers (i.e. {#AARRGGBB}).

See also
name()
Enumerator
HexRgb 
HexArgb 

Definition at line 72 of file qcolor.h.

◆ Spec

The type of color specified, either RGB, extended RGB, HSV, CMYK or HSL.

\value Rgb \value Hsv \value Cmyk \value Hsl \value ExtendedRgb \value Invalid

See also
spec(), convertTo()
Enumerator
Invalid 
Rgb 
Hsv 
Cmyk 
Hsl 
ExtendedRgb 

Definition at line 71 of file qcolor.h.

Constructor & Destructor Documentation

◆ QColor() [1/10]

QColor::QColor ( )
inlineconstexprnoexcept

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.

See also
isValid()

Definition at line 74 of file qcolor.h.

Here is the caller graph for this function:

◆ QColor() [2/10]

QColor::QColor ( Qt::GlobalColor  color)
noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Constructs a new color with a color value of color.

See also
isValid(), {QColor::Predefined Colors}{Predefined Colors}

Definition at line 686 of file qcolor.cpp.

Here is the call graph for this function:

◆ QColor() [3/10]

QColor::QColor ( int  r,
int  g,
int  b,
int  a = 255 
)
inlineconstexprnoexcept

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.

See also
setRgba(), isValid()

Definition at line 77 of file qcolor.h.

◆ QColor() [4/10]

QColor::QColor ( QRgb  color)
noexcept

Constructs a color with the value color. The alpha component is ignored and set to solid.

See also
fromRgb(), isValid()

Definition at line 761 of file qcolor.cpp.

Here is the call graph for this function:

◆ QColor() [5/10]

QColor::QColor ( QRgba64  rgba64)
noexcept
Since
5.6

Constructs a color with the value rgba64.

See also
fromRgba64()

Definition at line 779 of file qcolor.cpp.

◆ QColor() [6/10]

QColor::QColor ( const QString name)
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.

See also
setNamedColor(), name(), isValid()

Definition at line 304 of file qcolor.h.

Here is the call graph for this function:

◆ QColor() [7/10]

QColor::QColor ( QStringView  name)
inlineexplicit

Definition at line 301 of file qcolor.h.

Here is the call graph for this function:

◆ QColor() [8/10]

QColor::QColor ( const char *  name)
inline

Constructs a named color in the same way as setNamedColor() using the given name.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
setNamedColor(), name(), isValid()

Definition at line 88 of file qcolor.h.

◆ QColor() [9/10]

QColor::QColor ( QLatin1String  name)
inline

Constructs a named color in the same way as setNamedColor() using the given name.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.8
See also
setNamedColor(), name(), isValid()

Definition at line 298 of file qcolor.h.

Here is the call graph for this function:

◆ QColor() [10/10]

QColor::QColor ( Spec  spec)
noexcept

Definition at line 793 of file qcolor.cpp.

Member Function Documentation

◆ alpha()

int QColor::alpha ( ) const
noexcept

Returns the alpha color component of this color.

See also
setAlpha(), alphaF(), {QColor::Alpha-Blended Drawing}{Alpha-Blended Drawing}

Definition at line 1463 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ alphaF()

float QColor::alphaF ( ) const
noexcept

Returns the alpha color component of this color.

See also
setAlphaF(), alpha(), {QColor::Alpha-Blended Drawing}{Alpha-Blended Drawing}

Definition at line 1494 of file qcolor.cpp.

Here is the caller graph for this function:

◆ black()

int QColor::black ( ) const
noexcept

Returns the black color component of this color.

See also
blackF(), getCmyk(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 1948 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blackF()

float QColor::blackF ( ) const
noexcept

Returns the black color component of this color.

See also
black(), getCmykF(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 1996 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blue()

int QColor::blue ( ) const
noexcept

Returns the blue color component of this color.

See also
setBlue(), blueF(), getRgb()

Definition at line 1580 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blueF()

float QColor::blueF ( ) const
noexcept

Returns the blue color component of this color.

See also
setBlueF(), blue(), getRgbF()

Definition at line 1672 of file qcolor.cpp.

Here is the caller graph for this function:

◆ colorNames()

QStringList QColor::colorNames ( )
static

Returns a QStringList containing the color names Qt knows about.

See also
{QColor::Predefined Colors}{Predefined Colors}

Definition at line 996 of file qcolor.cpp.

Here is the caller graph for this function:

◆ convertTo()

QColor QColor::convertTo ( QColor::Spec  colorSpec) const
noexcept

Creates a copy of this color in the format specified by colorSpec.

See also
spec(), toCmyk(), toHsv(), toRgb(), isValid()

Definition at line 2333 of file qcolor.cpp.

Here is the caller graph for this function:

◆ cyan()

int QColor::cyan ( ) const
noexcept

Returns the cyan color component of this color.

See also
cyanF(), getCmyk(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 1911 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cyanF()

float QColor::cyanF ( ) const
noexcept

Returns the cyan color component of this color.

See also
cyan(), getCmykF(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 1960 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ darker()

QColor QColor::darker ( int  factor = 200) const
noexcept
Since
4.3

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 color to HSV, divides the value (V) component by factor and converts the color back to it's original color spec.

See also
lighter(), isValid()

Definition at line 2854 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromCmyk()

QColor QColor::fromCmyk ( int  c,
int  m,
int  y,
int  k,
int  a = 255 
)
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.

See also
toCmyk(), fromCmykF(), isValid(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 2738 of file qcolor.cpp.

Here is the call graph for this function:

◆ fromCmykF()

QColor QColor::fromCmykF ( float  c,
float  m,
float  y,
float  k,
float  a = 1.0 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

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.0-1.0.

See also
toCmyk(), fromCmyk(), isValid(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 2770 of file qcolor.cpp.

Here is the call graph for this function:

◆ fromHsl()

QColor QColor::fromHsl ( int  h,
int  s,
int  l,
int  a = 255 
)
static
Since
4.6

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 s, l, and a must all be in the range 0-255; the value of h must be in the range 0-359.

See also
toHsl(), fromHslF(), isValid(), {QColor::The HSL Color Model}{The HSL Color Model}

Definition at line 2559 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromHslF()

QColor QColor::fromHslF ( float  h,
float  s,
float  l,
float  a = 1.0 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
4.6

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

All the values must be in the range 0.0-1.0.

See also
toHsl(), fromHsl(), isValid(), {QColor::The HSL Color Model}{The HSL Color Model}

Definition at line 2591 of file qcolor.cpp.

Here is the call graph for this function:

◆ fromHsv()

QColor QColor::fromHsv ( int  h,
int  s,
int  v,
int  a = 255 
)
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.

See also
toHsv(), fromHsvF(), isValid(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 2496 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromHsvF()

QColor QColor::fromHsvF ( float  h,
float  s,
float  v,
float  a = 1.0 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

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

All the values must be in the range 0.0-1.0.

See also
toHsv(), fromHsv(), isValid(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 2527 of file qcolor.cpp.

Here is the call graph for this function:

◆ fromRgb() [1/2]

QColor QColor::fromRgb ( int  r,
int  g,
int  b,
int  a = 255 
)
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.

See also
toRgb(), fromRgba64(), fromRgbF(), isValid()

Definition at line 2396 of file qcolor.cpp.

Here is the call graph for this function:

◆ fromRgb() [2/2]

QColor QColor::fromRgb ( QRgb  rgb)
staticnoexcept

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.

See also
fromRgba(), fromRgbF(), toRgb(), isValid()

Definition at line 2366 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromRgba()

QColor QColor::fromRgba ( QRgb  rgba)
staticnoexcept

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.

See also
fromRgb(), fromRgba64(), isValid()

Definition at line 2382 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromRgba64() [1/2]

QColor QColor::fromRgba64 ( QRgba64  rgba64)
staticnoexcept
Since
5.6

Static convenience function that returns a QColor constructed from the given QRgba64 value rgba64.

See also
fromRgb(), fromRgbF(), toRgb(), isValid()

Definition at line 2479 of file qcolor.cpp.

◆ fromRgba64() [2/2]

QColor QColor::fromRgba64 ( ushort  r,
ushort  g,
ushort  b,
ushort  a = USHRT_MAX 
)
staticnoexcept
Since
5.6

Static convenience function that returns a QColor constructed from the RGBA64 color values, r (red), g (green), b (blue), and a (alpha-channel, i.e. transparency).

See also
fromRgb(), fromRgbF(), toRgb(), isValid()

Definition at line 2464 of file qcolor.cpp.

Here is the call graph for this function:

◆ fromRgbF()

QColor QColor::fromRgbF ( float  r,
float  g,
float  b,
float  a = 1.0 
)
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).

The alpha value must be in the range 0.0-1.0. If any of the other values are outside the range of 0.0-1.0 the color model will be set as ExtendedRgb.

See also
fromRgb(), fromRgba64(), toRgb(), isValid()

Definition at line 2424 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCmyk()

void QColor::getCmyk ( int *  c,
int *  m,
int *  y,
int *  k,
int *  a = nullptr 
) const

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.

See also
setCmyk(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 2623 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCmykF()

void QColor::getCmykF ( float *  c,
float *  m,
float *  y,
float *  k,
float *  a = nullptr 
) const

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.

See also
setCmykF(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 2652 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHsl()

void QColor::getHsl ( int *  h,
int *  s,
int *  l,
int *  a = nullptr 
) const
Since
4.6

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 hslHue(), hslSaturation(), lightness() and alpha() functions.

See also
getHslF(), setHsl(), {QColor::The HSL Color Model}{The HSL Color Model}

Definition at line 1151 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHslF()

void QColor::getHslF ( float *  h,
float *  s,
float *  l,
float *  a = nullptr 
) const
Since
4.6

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 hslHueF(), hslSaturationF(), lightnessF() and alphaF() functions.

See also
getHsl(), setHslF(), {QColor::The HSL Color Model}{The HSL Color Model}

Definition at line 1121 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHsv()

void QColor::getHsv ( int *  h,
int *  s,
int *  v,
int *  a = nullptr 
) 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.

See also
setHsv(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1039 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHsvF()

void QColor::getHsvF ( float *  h,
float *  s,
float *  v,
float *  a = nullptr 
) 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 hueF(), saturationF(), valueF() and alphaF() functions.

See also
setHsv(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1011 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRgb()

void QColor::getRgb ( int *  r,
int *  g,
int *  b,
int *  a = nullptr 
) 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.

See also
rgb(), setRgb()

Definition at line 1284 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRgbF()

void QColor::getRgbF ( float *  r,
float *  g,
float *  b,
float *  a = nullptr 
) 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 redF(), greenF(), blueF() and alphaF() functions.

See also
rgb(), setRgb()

Definition at line 1246 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ green()

int QColor::green ( ) const
noexcept

Returns the green color component of this color.

See also
setGreen(), greenF(), getRgb()

Definition at line 1552 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ greenF()

float QColor::greenF ( ) const
noexcept

Returns the green color component of this color.

See also
setGreenF(), green(), getRgbF()

Definition at line 1640 of file qcolor.cpp.

Here is the caller graph for this function:

◆ hslHue()

int QColor::hslHue ( ) const
noexcept
Since
4.6

Returns the HSL hue color component of this color.

See also
hslHueF(), hsvHue(), getHsl(), {QColor::The HSL Color Model}{The HSL Color Model}

Definition at line 1829 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hslHueF()

float QColor::hslHueF ( ) const
noexcept
Since
4.6

Returns the HSL hue color component of this color.

See also
hslHue(), hsvHueF(), getHslF()

Definition at line 1871 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hslSaturation()

int QColor::hslSaturation ( ) const
noexcept
Since
4.6

Returns the HSL saturation color component of this color.

See also
hslSaturationF(), hsvSaturation(), getHsl(), {QColor::The HSL Color Model}{The HSL Color Model}

Definition at line 1843 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hslSaturationF()

float QColor::hslSaturationF ( ) const
noexcept
Since
4.6

Returns the HSL saturation color component of this color.

See also
hslSaturation(), hsvSaturationF(), getHslF(), {QColor::The HSL Color Model}{The HSL Color Model}

Definition at line 1885 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hsvHue()

int QColor::hsvHue ( ) const
noexcept

Returns the HSV hue color component of this color.

See also
hueF(), hslHue(), getHsv(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1715 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hsvHueF()

float QColor::hsvHueF ( ) const
noexcept

Returns the hue color component of this color.

See also
hue(), hslHueF(), getHsvF(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1778 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hsvSaturation()

int QColor::hsvSaturation ( ) const
noexcept

Returns the HSV saturation color component of this color.

See also
saturationF(), hslSaturation(), getHsv(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1741 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hsvSaturationF()

float QColor::hsvSaturationF ( ) const
noexcept

Returns the HSV saturation color component of this color.

See also
saturation(), hslSaturationF(), getHsvF(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1803 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hue()

int QColor::hue ( ) const
noexcept

Returns the HSV hue color component of this color.

The color is implicitly converted to HSV.

See also
hsvHue(), hslHue(), hueF(), getHsv(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1705 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hueF()

float QColor::hueF ( ) const
noexcept

Returns the HSV hue color component of this color.

The color is implicitly converted to HSV.

See also
hsvHueF(), hslHueF(), hue(), getHsvF(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1767 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValid()

bool QColor::isValid ( ) const
inlinenoexcept

Returns true if the color is valid; otherwise returns false.

Definition at line 307 of file qcolor.h.

Here is the caller graph for this function:

◆ isValidColor() [1/3]

bool QColor::isValidColor ( const QString name)
static
Since
4.7

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().

See also
setNamedColor()

Definition at line 936 of file qcolor.cpp.

Here is the call graph for this function:

◆ isValidColor() [2/3]

bool QColor::isValidColor ( QLatin1String  name)
staticnoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.8

Definition at line 954 of file qcolor.cpp.

◆ isValidColor() [3/3]

bool QColor::isValidColor ( QStringView  name)
staticnoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.10

Definition at line 945 of file qcolor.cpp.

◆ lighter()

QColor QColor::lighter ( int  factor = 150) const
noexcept
Since
4.3

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 color to HSV, multiplies the value (V) component by factor and converts the color back to it's original color spec.

See also
darker(), isValid()

Definition at line 2809 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lightness()

int QColor::lightness ( ) const
noexcept
Since
4.6

Returns the lightness color component of this color.

See also
lightnessF(), getHsl()

Definition at line 1857 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lightnessF()

float QColor::lightnessF ( ) const
noexcept
Since
4.6

Returns the lightness color component of this color.

See also
value(), getHslF()

Definition at line 1899 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ magenta()

int QColor::magenta ( ) const
noexcept

Returns the magenta color component of this color.

See also
magentaF(), getCmyk(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 1923 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ magentaF()

float QColor::magentaF ( ) const
noexcept

Returns the magenta color component of this color.

See also
magenta(), getCmykF(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 1972 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ name()

QString QColor::name ( NameFormat  format = HexRgb) const
Since
5.2

Returns the name of the color in the specified format.

See also
setNamedColor(), NameFormat

Definition at line 864 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator QVariant()

QColor::operator QVariant ( ) const

Returns the color as a QVariant

Definition at line 2919 of file qcolor.cpp.

Here is the call graph for this function:

◆ operator!=()

bool QColor::operator!= ( const QColor color) const
noexcept

Returns true if this color has different color specification or component values from color; otherwise returns false.

ExtendedRgb and Rgb specifications are considered matching in this context.

See also
spec()

Definition at line 2912 of file qcolor.cpp.

Here is the call graph for this function:

◆ operator=()

QColor & QColor::operator= ( Qt::GlobalColor  color)
noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Assigns a copy of color and returns a reference to this color.

Definition at line 2871 of file qcolor.cpp.

◆ operator==()

bool QColor::operator== ( const QColor color) const
noexcept

Returns true if this color has the same color specification and component values as color; otherwise returns false.

ExtendedRgb and Rgb specifications are considered matching in this context.

See also
spec()

Definition at line 2884 of file qcolor.cpp.

Here is the call graph for this function:

◆ red()

int QColor::red ( ) const
noexcept

Returns the red color component of this color.

See also
setRed(), redF(), getRgb()

Definition at line 1525 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ redF()

float QColor::redF ( ) const
noexcept

Returns the red color component of this color.

See also
setRedF(), red(), getRgbF()

Definition at line 1608 of file qcolor.cpp.

Here is the caller graph for this function:

◆ rgb()

QRgb QColor::rgb ( ) const
noexcept

Returns the RGB value of the color. The alpha value is opaque.

See also
getRgb(), rgba()

Definition at line 1436 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rgba()

QRgb QColor::rgba ( ) const
noexcept

Returns the RGB value of the color, including its alpha.

For an invalid color, the alpha value of the returned color is unspecified.

See also
setRgba(), rgb(), rgba64()

Definition at line 1373 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rgba64()

QRgba64 QColor::rgba64 ( ) const
noexcept
Since
5.6

Returns the RGB64 value of the color, including its alpha.

For an invalid color, the alpha value of the returned color is unspecified.

See also
setRgba64(), rgba(), rgb()

Definition at line 1405 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saturation()

int QColor::saturation ( ) const
noexcept

Returns the HSV saturation color component of this color.

The color is implicitly converted to HSV.

See also
hsvSaturation(), hslSaturation(), saturationF(), getHsv(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1731 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saturationF()

float QColor::saturationF ( ) const
noexcept

Returns the HSV saturation color component of this color.

The color is implicitly converted to HSV.

See also
hsvSaturationF(), hslSaturationF(), saturation(), getHsvF(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1793 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAlpha()

void QColor::setAlpha ( int  alpha)

Sets the alpha of this color to alpha. Integer alpha is specified in the range 0-255.

See also
alpha(), alphaF(), {QColor::Alpha-Blended Drawing}{Alpha-Blended Drawing}

Definition at line 1478 of file qcolor.cpp.

Here is the caller graph for this function:

◆ setAlphaF()

void QColor::setAlphaF ( float  alpha)

Sets the alpha of this color to alpha. float alpha is specified in the range 0.0-1.0.

See also
alphaF(), alpha(), {QColor::Alpha-Blended Drawing}{Alpha-Blended Drawing}

Definition at line 1508 of file qcolor.cpp.

◆ setBlue()

void QColor::setBlue ( int  blue)

Sets the blue color component of this color to blue. Integer components are specified in the range 0-255.

See also
blue(), blueF(), setRgb()

Definition at line 1594 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBlueF()

void QColor::setBlueF ( float  blue)

Sets the blue color component of this color to blue. If blue lies outside the 0.0-1.0 range, the color model will be changed to ExtendedRgb.

See also
blueF(), blue(), setRgbF()

Definition at line 1687 of file qcolor.cpp.

Here is the call graph for this function:

◆ setCmyk()

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.

See also
getCmyk(), setCmykF(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 2679 of file qcolor.cpp.

◆ setCmykF()

void QColor::setCmykF ( float  c,
float  m,
float  y,
float  k,
float  a = 1.0 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

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.0-1.0.

See also
getCmykF(), setCmyk(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 2709 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGreen()

void QColor::setGreen ( int  green)

Sets the green color component of this color to green. Integer components are specified in the range 0-255.

See also
green(), greenF(), setRgb()

Definition at line 1565 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGreenF()

void QColor::setGreenF ( float  green)

Sets the green color component of this color to green. If green lies outside the 0.0-1.0 range, the color model will be changed to ExtendedRgb.

See also
greenF(), green(), setRgbF()

Definition at line 1657 of file qcolor.cpp.

Here is the call graph for this function:

◆ setHsl()

void QColor::setHsl ( int  h,
int  s,
int  l,
int  a = 255 
)
Since
4.6

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.

See also
getHsl(), setHslF()

Definition at line 1209 of file qcolor.cpp.

◆ setHslF()

void QColor::setHslF ( float  h,
float  s,
float  l,
float  a = 1.0 
)
Since
4.6

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.

See also
getHslF(), setHsl()

Definition at line 1179 of file qcolor.cpp.

Here is the call graph for this function:

◆ setHsv()

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.

See also
getHsv(), setHsvF(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1093 of file qcolor.cpp.

◆ setHsvF()

void QColor::setHsvF ( float  h,
float  s,
float  v,
float  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.

All the values must be in the range 0.0-1.0.

See also
getHsvF(), setHsv(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1065 of file qcolor.cpp.

Here is the call graph for this function:

◆ setNamedColor() [1/3]

void QColor::setNamedColor ( const QString name)

Sets the RGB value of this QColor to name, which may be in one of these formats:

\list

  • #RGB (each of R, G, and B is a single hex digit)
  • #RRGGBB
  • #AARRGGBB (Since 5.2)
  • #RRRGGGBBB
  • #RRRRGGGGBBBB
  • A name from the list of colors defined in the list of \l{https://www.w3.org/TR/SVG11/types.html#ColorKeywords}{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.
  • transparent - representing the absence of a color. \endlist

The color is invalid if name cannot be parsed.

See also
QColor(), name(), isValid()

Definition at line 900 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setNamedColor() [2/3]

void QColor::setNamedColor ( QLatin1String  name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.8

Definition at line 920 of file qcolor.cpp.

◆ setNamedColor() [3/3]

void QColor::setNamedColor ( QStringView  name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.10

Definition at line 910 of file qcolor.cpp.

◆ setRed()

void QColor::setRed ( int  red)

Sets the red color component of this color to red. Integer components are specified in the range 0-255.

See also
red(), redF(), setRgb()

Definition at line 1538 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRedF()

void QColor::setRedF ( float  red)

Sets the red color component of this color to red. If red lies outside the 0.0-1.0 range, the color model will be changed to ExtendedRgb.

See also
redF(), red(), setRgbF()

Definition at line 1625 of file qcolor.cpp.

Here is the call graph for this function:

◆ setRgb() [1/2]

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.

See also
rgb(), getRgb(), setRgbF()

Definition at line 1347 of file qcolor.cpp.

Here is the caller graph for this function:

◆ setRgb() [2/2]

void QColor::setRgb ( QRgb  rgb)
noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Sets the RGB value to rgb. The alpha value is set to opaque.

Definition at line 1448 of file qcolor.cpp.

Here is the call graph for this function:

◆ setRgba()

void QColor::setRgba ( QRgb  rgba)
noexcept

Sets the RGB value to rgba, including its alpha.

See also
rgba(), rgb(), setRgba64()

Definition at line 1385 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRgba64()

void QColor::setRgba64 ( QRgba64  rgba)
noexcept
Since
5.6

Sets the RGB64 value to rgba, including its alpha.

See also
setRgba(), rgba64()

Definition at line 1419 of file qcolor.cpp.

Here is the call graph for this function:

◆ setRgbF()

void QColor::setRgbF ( float  r,
float  g,
float  b,
float  a = 1.0 
)

Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency).

The alpha value must be in the range 0.0-1.0. If any of the other values are outside the range of 0.0-1.0 the color model will be set as ExtendedRgb.

See also
rgb(), getRgbF(), setRgb()

Definition at line 1314 of file qcolor.cpp.

Here is the caller graph for this function:

◆ spec()

Spec QColor::spec ( ) const
inlinenoexcept

Returns how the color was specified.

See also
Spec, convertTo()

Definition at line 104 of file qcolor.h.

Here is the caller graph for this function:

◆ toCmyk()

QColor QColor::toCmyk ( ) const
noexcept

Creates and returns a CMYK QColor based on this color.

See also
fromCmyk(), convertTo(), isValid(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 2292 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toExtendedRgb()

QColor QColor::toExtendedRgb ( ) const
noexcept

Create and returns an extended RGB QColor based on this color.

Since
5.14
See also
toRgb, convertTo()

Definition at line 2009 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toHsl()

QColor QColor::toHsl ( ) const
noexcept

Creates and returns an HSL QColor based on this color.

See also
fromHsl(), convertTo(), isValid(), {QColor::The HSL Color Model}{The HSL Color Model}

Definition at line 2236 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toHsv()

QColor QColor::toHsv ( ) const
noexcept

Creates and returns an HSV QColor based on this color.

See also
fromHsv(), convertTo(), isValid(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 2185 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toRgb()

QColor QColor::toRgb ( ) const
noexcept

Create and returns an RGB QColor based on this color.

See also
fromRgb(), convertTo(), isValid()

Definition at line 2032 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ value()

int QColor::value ( ) const
noexcept

Returns the value color component of this color.

See also
valueF(), getHsv(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1753 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ valueF()

float QColor::valueF ( ) const
noexcept

Returns the value color component of this color.

See also
value(), getHsvF(), {QColor::The HSV Color Model}{The HSV Color Model}

Definition at line 1815 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yellow()

int QColor::yellow ( ) const
noexcept

Returns the yellow color component of this color.

See also
yellowF(), getCmyk(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 1935 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yellowF()

float QColor::yellowF ( ) const
noexcept

Returns the yellow color component of this color.

See also
yellow(), getCmykF(), {QColor::The CMYK Color Model}{The CMYK Color Model}

Definition at line 1984 of file qcolor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<< [1/2]

QDataStream & operator<< ( QDataStream stream,
const QColor color 
)
friend

Writes the color to the stream.

See also
{Serializing Qt Data Types}

Definition at line 2974 of file qcolor.cpp.

◆ operator<<() [2/2]

QDataStream & operator<< ( QDataStream stream,
const QColor color 
)
related

Writes the color to the stream.

See also
{Serializing Qt Data Types}

Definition at line 2974 of file qcolor.cpp.

◆ operator>> [1/2]

QDataStream & operator>> ( QDataStream stream,
QColor color 
)
friend

Reads the color from the stream.

See also
{Serializing Qt Data Types}

Definition at line 3010 of file qcolor.cpp.

◆ operator>>() [2/2]

QDataStream & operator>> ( QDataStream stream,
QColor color 
)
related

Reads the color from the stream.

See also
{Serializing Qt Data Types}

Definition at line 3010 of file qcolor.cpp.

◆ qAlpha()

int qAlpha ( QRgb  rgba)
related

Returns the alpha component of the ARGB quadruplet rgba.

See also
qRgb(), QColor::alpha()

Definition at line 63 of file qrgb.h.

Here is the caller graph for this function:

◆ qBlue()

int qBlue ( QRgb  rgb)
related

Returns the blue component of the ARGB quadruplet rgb.

See also
qRgb(), QColor::blue()

Definition at line 60 of file qrgb.h.

Here is the caller graph for this function:

◆ QColormap

friend class QColormap
friend

Definition at line 284 of file qcolor.h.

◆ qGray() [1/2]

int qGray ( int  r,
int  g,
int  b 
)
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 72 of file qrgb.h.

Here is the caller graph for this function:

◆ qGray() [2/2]

int qGray ( QRgb  rgb)
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.

Definition at line 75 of file qrgb.h.

Here is the call graph for this function:

◆ qGreen()

int qGreen ( QRgb  rgb)
related

Returns the green component of the ARGB quadruplet rgb.

See also
qRgb(), QColor::green()

Definition at line 57 of file qrgb.h.

Here is the caller graph for this function:

◆ qPremultiply()

QRgb qPremultiply ( QRgb  rgb)
related
Since
5.3

Converts an unpremultiplied ARGB quadruplet rgb into a premultiplied ARGB quadruplet.

See also
qUnpremultiply()

Definition at line 81 of file qrgb.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qRed()

int qRed ( QRgb  rgb)
related

Returns the red component of the ARGB quadruplet rgb.

See also
qRgb(), QColor::red()

Definition at line 54 of file qrgb.h.

Here is the caller graph for this function:

◆ qRgb()

QRgb qRgb ( int  r,
int  g,
int  b 
)
related

Returns the ARGB quadruplet (255, {r}, {g}, {b}).

See also
qRgba(), qRed(), qGreen(), qBlue(), qAlpha()

Definition at line 66 of file qrgb.h.

Here is the caller graph for this function:

◆ QRgb()

QRgb
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 \l{QColor::Alpha-Blended Drawing}{Alpha-Blended Drawing} section.

Here are some examples of how QRgb values can be created:

See also
qRgb(), qRgba(), QColor::rgb(), QColor::rgba()

Definition at line 49 of file qrgb.h.

Here is the caller graph for this function:

◆ qRgba()

QRgb qRgba ( int  r,
int  g,
int  b,
int  a 
)
related

Returns the ARGB quadruplet ({a}, {r}, {g}, {b}).

See also
qRgb(), qRed(), qGreen(), qBlue(), qAlpha()

Definition at line 69 of file qrgb.h.

Here is the caller graph for this function:

◆ qUnpremultiply()

QRgb qUnpremultiply ( QRgb  rgb)
related
Since
5.3

Converts a premultiplied ARGB quadruplet rgb into an unpremultiplied ARGB quadruplet.

See also
qPremultiply()

Definition at line 96 of file qrgb.h.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: