- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Friends

# QColor Class Reference

Search for all occurrences

## Detailed Description

Definition at line 67 of file qcolor.h.

`#include <qcolor.h>`

List of all members.

## Public Types
enum | Spec { Invalid, Rgb, Hsv, Cmyk, Hsl }
## Public Member Functions
| QColor ()
| QColor (Qt::GlobalColor color)
| QColor (int r, int g, int b, int a=255)
| QColor (QRgb rgb)
| QColor (const QString &name)
| QColor (const char *name)
| QColor (const QColor &color)
| QColor (Spec spec)
bool | isValid () const
QString | name () const
void | setNamedColor (const QString &name)
Spec | spec () const
int | alpha () const
void | setAlpha (int alpha)
qreal | alphaF () const
void | setAlphaF (qreal alpha)
int | red () const
int | green () const
int | blue () const
void | setRed (int red)
void | setGreen (int green)
void | setBlue (int blue)
qreal | redF () const
qreal | greenF () const
qreal | blueF () const
void | setRedF (qreal red)
void | setGreenF (qreal green)
void | setBlueF (qreal blue)
void | getRgb (int *r, int *g, int *b, int *a=0) const
void | setRgb (int r, int g, int b, int a=255)
void | getRgbF (qreal *r, qreal *g, qreal *b, qreal *a=0) const
void | setRgbF (qreal r, qreal g, qreal b, qreal a=1.0)
QRgb | rgba () const
void | setRgba (QRgb rgba)
QRgb | rgb () const
void | setRgb (QRgb rgb)
int | hue () const
int | saturation () const
int | hsvHue () const
int | hsvSaturation () const
int | value () const
qreal | hueF () const
qreal | saturationF () const
qreal | hsvHueF () const
qreal | hsvSaturationF () const
qreal | valueF () const
void | getHsv (int *h, int *s, int *v, int *a=0) const
void | setHsv (int h, int s, int v, int a=255)
void | getHsvF (qreal *h, qreal *s, qreal *v, qreal *a=0) const
void | setHsvF (qreal h, qreal s, qreal v, qreal a=1.0)
int | cyan () const
int | magenta () const
int | yellow () const
int | black () const
qreal | cyanF () const
qreal | magentaF () const
qreal | yellowF () const
qreal | blackF () const
void | getCmyk (int *c, int *m, int *y, int *k, int *a=0)
void | setCmyk (int c, int m, int y, int k, int a=255)
void | getCmykF (qreal *c, qreal *m, qreal *y, qreal *k, qreal *a=0)
void | setCmykF (qreal c, qreal m, qreal y, qreal k, qreal a=1.0)
int | hslHue () const
int | hslSaturation () const
int | lightness () const
qreal | hslHueF () const
qreal | hslSaturationF () const
qreal | lightnessF () const
void | getHsl (int *h, int *s, int *l, int *a=0) const
void | setHsl (int h, int s, int l, int a=255)
void | getHslF (qreal *h, qreal *s, qreal *l, qreal *a=0) const
void | setHslF (qreal h, qreal s, qreal l, qreal a=1.0)
QColor | toRgb () const
QColor | toHsv () const
QColor | toCmyk () const
QColor | toHsl () const
QColor | convertTo (Spec colorSpec) const
QColor | light (int f=150) const
QColor | lighter (int f=150) const
QColor | dark (int f=200) const
QColor | darker (int f=200) const
QColor & | operator= (const QColor &)
QColor & | operator= (Qt::GlobalColor color)
bool | operator== (const QColor &c) const
bool | operator!= (const QColor &c) const
| operator QVariant () const
## Static Public Member Functions
static QStringList | colorNames ()
static QColor | fromRgb (QRgb rgb)
static QColor | fromRgba (QRgb rgba)
static QColor | fromRgb (int r, int g, int b, int a=255)
static QColor | fromRgbF (qreal r, qreal g, qreal b, qreal a=1.0)
static QColor | fromHsv (int h, int s, int v, int a=255)
static QColor | fromHsvF (qreal h, qreal s, qreal v, qreal a=1.0)
static QColor | fromCmyk (int c, int m, int y, int k, int a=255)
static QColor | fromCmykF (qreal c, qreal m, qreal y, qreal k, qreal a=1.0)
static QColor | fromHsl (int h, int s, int l, int a=255)
static QColor | fromHslF (qreal h, qreal s, qreal l, qreal a=1.0)
static bool | isValidColor (const QString &name)
## Friends
class | QColormap
Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &, const QColor &)
Q_GUI_EXPORT QDataStream & | operator>> (QDataStream &, QColor &)

## Member Enumeration Documentation

enum Spec

Search for all occurrences

Enumerator:

  Invalid | Search for all occurrences
  Rgb | Search for all occurrences
  Hsv | Search for all occurrences
  Cmyk | Search for all occurrences
  Hsl | Search for all occurrences

Definition at line 70 of file qcolor.h.

    { Invalid, Rgb, Hsv, Cmyk, Hsl };

## Constructor & Destructor Documentation

QColor | ( |  | ) | `[inline]`

Definition at line 279 of file qcolor.h.

    { invalidate(); }

QColor | ( | Qt::GlobalColor | color | ) |

QColor | ( | int | r,
|  | int | g,
|  | int | b,
|  | int | a = `255`
| ) |  | `[inline]`

Definition at line 282 of file qcolor.h.

    { setRgb(r, g, b, a); }

QColor | ( | QRgb | rgb | ) |

QColor | ( | const QString & | name | ) | `[inline]`

Definition at line 288 of file qcolor.h.

    { setNamedColor(aname); }

QColor | ( | const char * | name | ) | `[inline]`

Definition at line 285 of file qcolor.h.

    { setNamedColor(QLatin1String(aname)); }

QColor | ( | const QColor & | color | ) | `[inline]`

Definition at line 291 of file qcolor.h.

        : cspec(acolor.cspec)
    { ct.argb = acolor.ct.argb; }

QColor | ( | Spec | spec | ) |

## Member Function Documentation

bool isValid | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 295 of file qcolor.h.

    { return cspec != Invalid; }

QString name | ( |  | ) | const

Search for all occurrences

void setNamedColor | ( | const QString & | name | ) |

Search for all occurrences

static QStringList colorNames | ( |  | ) | `[static]`

Search for all occurrences

Spec spec | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 88 of file qcolor.h.

        { return cspec; }

int alpha | ( |  | ) | const

Search for all occurrences

void setAlpha | ( | int | alpha | ) |

Search for all occurrences

qreal alphaF | ( |  | ) | const

Search for all occurrences

void setAlphaF | ( | qreal | alpha | ) |

Search for all occurrences

int red | ( |  | ) | const

Search for all occurrences

int green | ( |  | ) | const

Search for all occurrences

int blue | ( |  | ) | const

Search for all occurrences

void setRed | ( | int | red | ) |

Search for all occurrences

void setGreen | ( | int | green | ) |

Search for all occurrences

void setBlue | ( | int | blue | ) |

Search for all occurrences

qreal redF | ( |  | ) | const

Search for all occurrences

qreal greenF | ( |  | ) | const

Search for all occurrences

qreal blueF | ( |  | ) | const

Search for all occurrences

void setRedF | ( | qreal | red | ) |

Search for all occurrences

void setGreenF | ( | qreal | green | ) |

Search for all occurrences

void setBlueF | ( | qreal | blue | ) |

Search for all occurrences

void getRgb | ( | int * | r,
|  | int * | g,
|  | int * | b,
|  | int * | a = `0`
| ) |  | const

Search for all occurrences

void setRgb | ( | int | r,
|  | int | g,
|  | int | b,
|  | int | a = `255`
| ) |  |

Search for all occurrences

void getRgbF | ( | qreal * | r,
|  | qreal * | g,
|  | qreal * | b,
|  | qreal * | a = `0`
| ) |  | const

Search for all occurrences

void setRgbF | ( | qreal | r,
|  | qreal | g,
|  | qreal | b,
|  | qreal | a = `1.0`
| ) |  |

Search for all occurrences

QRgb rgba | ( |  | ) | const

Search for all occurrences

void setRgba | ( | QRgb | rgba | ) |

Search for all occurrences

QRgb rgb | ( |  | ) | const

Search for all occurrences

void setRgb | ( | QRgb | rgb | ) |

Search for all occurrences

int hue | ( |  | ) | const

Search for all occurrences

int saturation | ( |  | ) | const

Search for all occurrences

int hsvHue | ( |  | ) | const

Search for all occurrences

int hsvSaturation | ( |  | ) | const

Search for all occurrences

int value | ( |  | ) | const

Search for all occurrences

qreal hueF | ( |  | ) | const

Search for all occurrences

qreal saturationF | ( |  | ) | const

Search for all occurrences

qreal hsvHueF | ( |  | ) | const

Search for all occurrences

qreal hsvSaturationF | ( |  | ) | const

Search for all occurrences

qreal valueF | ( |  | ) | const

Search for all occurrences

void getHsv | ( | int * | h,
|  | int * | s,
|  | int * | v,
|  | int * | a = `0`
| ) |  | const

Search for all occurrences

void setHsv | ( | int | h,
|  | int | s,
|  | int | v,
|  | int | a = `255`
| ) |  |

Search for all occurrences

void getHsvF | ( | qreal * | h,
|  | qreal * | s,
|  | qreal * | v,
|  | qreal * | a = `0`
| ) |  | const

Search for all occurrences

void setHsvF | ( | qreal | h,
|  | qreal | s,
|  | qreal | v,
|  | qreal | a = `1.0`
| ) |  |

Search for all occurrences

int cyan | ( |  | ) | const

Search for all occurrences

int magenta | ( |  | ) | const

Search for all occurrences

int yellow | ( |  | ) | const

Search for all occurrences

int black | ( |  | ) | const

Search for all occurrences

qreal cyanF | ( |  | ) | const

Search for all occurrences

qreal magentaF | ( |  | ) | const

Search for all occurrences

qreal yellowF | ( |  | ) | const

Search for all occurrences

qreal blackF | ( |  | ) | const

Search for all occurrences

void getCmyk | ( | int * | c,
|  | int * | m,
|  | int * | y,
|  | int * | k,
|  | int * | a = `0`
| ) |  |

Search for all occurrences

void setCmyk | ( | int | c,
|  | int | m,
|  | int | y,
|  | int | k,
|  | int | a = `255`
| ) |  |

Search for all occurrences

void getCmykF | ( | qreal * | c,
|  | qreal * | m,
|  | qreal * | y,
|  | qreal * | k,
|  | qreal * | a = `0`
| ) |  |

Search for all occurrences

void setCmykF | ( | qreal | c,
|  | qreal | m,
|  | qreal | y,
|  | qreal | k,
|  | qreal | a = `1.0`
| ) |  |

Search for all occurrences

int hslHue | ( |  | ) | const

Search for all occurrences

int hslSaturation | ( |  | ) | const

Search for all occurrences

int lightness | ( |  | ) | const

Search for all occurrences

qreal hslHueF | ( |  | ) | const

Search for all occurrences

qreal hslSaturationF | ( |  | ) | const

Search for all occurrences

qreal lightnessF | ( |  | ) | const

Search for all occurrences

void getHsl | ( | int * | h,
|  | int * | s,
|  | int * | l,
|  | int * | a = `0`
| ) |  | const

Search for all occurrences

void setHsl | ( | int | h,
|  | int | s,
|  | int | l,
|  | int | a = `255`
| ) |  |

Search for all occurrences

void getHslF | ( | qreal * | h,
|  | qreal * | s,
|  | qreal * | l,
|  | qreal * | a = `0`
| ) |  | const

Search for all occurrences

void setHslF | ( | qreal | h,
|  | qreal | s,
|  | qreal | l,
|  | qreal | a = `1.0`
| ) |  |

Search for all occurrences

QColor toRgb | ( |  | ) | const

Search for all occurrences

QColor toHsv | ( |  | ) | const

Search for all occurrences

QColor toCmyk | ( |  | ) | const

Search for all occurrences

QColor toHsl | ( |  | ) | const

Search for all occurrences

QColor convertTo | ( | Spec | colorSpec | ) | const

Search for all occurrences

static QColor fromRgb | ( | QRgb | rgb | ) | `[static]`

Search for all occurrences

static QColor fromRgba | ( | QRgb | rgba | ) | `[static]`

Search for all occurrences

static QColor fromRgb | ( | int | r,
|  | int | g,
|  | int | b,
|  | int | a = `255`
| ) |  | `[static]`

Search for all occurrences

static QColor fromRgbF | ( | qreal | r,
|  | qreal | g,
|  | qreal | b,
|  | qreal | a = `1.0`
| ) |  | `[static]`

Search for all occurrences

static QColor fromHsv | ( | int | h,
|  | int | s,
|  | int | v,
|  | int | a = `255`
| ) |  | `[static]`

Search for all occurrences

static QColor fromHsvF | ( | qreal | h,
|  | qreal | s,
|  | qreal | v,
|  | qreal | a = `1.0`
| ) |  | `[static]`

Search for all occurrences

static QColor fromCmyk | ( | int | c,
|  | int | m,
|  | int | y,
|  | int | k,
|  | int | a = `255`
| ) |  | `[static]`

Search for all occurrences

static QColor fromCmykF | ( | qreal | c,
|  | qreal | m,
|  | qreal | y,
|  | qreal | k,
|  | qreal | a = `1.0`
| ) |  | `[static]`

Search for all occurrences

static QColor fromHsl | ( | int | h,
|  | int | s,
|  | int | l,
|  | int | a = `255`
| ) |  | `[static]`

Search for all occurrences

static QColor fromHslF | ( | qreal | h,
|  | qreal | s,
|  | qreal | l,
|  | qreal | a = `1.0`
| ) |  | `[static]`

Search for all occurrences

QColor light | ( | int | f = `150` | ) | const

Search for all occurrences

QColor lighter | ( | int | f = `150` | ) | const `[inline]`

Search for all occurrences

Definition at line 298 of file qcolor.h.

    { return light(f); }

QColor dark | ( | int | f = `200` | ) | const

Search for all occurrences

QColor darker | ( | int | f = `200` | ) | const `[inline]`

Search for all occurrences

Definition at line 301 of file qcolor.h.

    { return dark(f); }

QColor& operator= | ( | const QColor & |  | ) |

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

bool operator== | ( | const QColor & | c | ) | const

bool operator!= | ( | const QColor & | c | ) | const

operator QVariant | ( |  | ) | const

static bool isValidColor | ( | const QString & | name | ) | `[static]`

Search for all occurrences

## Friends And Related Function Documentation

friend class QColormap `[friend]`

Search for all occurrences

Definition at line 272 of file qcolor.h.

Q_GUI_EXPORT QDataStream& operator<< | ( | QDataStream & | ,
|  | const QColor & |
| ) |  | `[friend]`

Q_GUI_EXPORT QDataStream& operator>> | ( | QDataStream & | ,
|  | QColor & |
| ) |  | `[friend]`

## Member Data Documentation

ushort alpha

Search for all occurrences

Definition at line 242 of file qcolor.h.

ushort red

Search for all occurrences

Definition at line 243 of file qcolor.h.

ushort green

Search for all occurrences

Definition at line 244 of file qcolor.h.

ushort blue

Search for all occurrences

Definition at line 245 of file qcolor.h.

ushort pad

Search for all occurrences

Definition at line 246 of file qcolor.h.

struct { ... } argb

Search for all occurrences

ushort hue

Search for all occurrences

Definition at line 250 of file qcolor.h.

ushort saturation

Search for all occurrences

Definition at line 251 of file qcolor.h.

ushort value

Search for all occurrences

Definition at line 252 of file qcolor.h.

struct { ... } ahsv

Search for all occurrences

ushort cyan

Search for all occurrences

Definition at line 257 of file qcolor.h.

ushort magenta

Search for all occurrences

Definition at line 258 of file qcolor.h.

ushort yellow

Search for all occurrences

Definition at line 259 of file qcolor.h.

ushort black

Search for all occurrences

Definition at line 260 of file qcolor.h.

struct { ... } acmyk

Search for all occurrences

ushort lightness

Search for all occurrences

Definition at line 266 of file qcolor.h.

struct { ... } ahsl

Search for all occurrences

ushort array[5]

Search for all occurrences

Definition at line 269 of file qcolor.h.

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

- QtGui/qcolor.h

QColor QColor QColor QColor QColor QColor QColor QColor QColor QColor
QColor QColor QColor QColor QColor QColor QColor QColor QColor QColor