|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.gui.QColor
public class QColor
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.
![]() | ![]() | ![]() |
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.Alpha-Blended Drawing
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:
// Specify semi-transparent red painter.setBrush(new QColor(255, 0, 0, 127)); painter.drawRect(0, 0, width()/2, height()); // Specify semi-transparent blue painter.setBrush(new QColor(0, 0, 255, 127)); painter.drawRect(0, 0, width(), height()/2);The code above produces the following output:
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.Predefined Colors
There are 20 predefined QColors: Qt::white
, Qt::black
, Qt::red
, Qt::darkRed
, Qt::green
, Qt::darkGreen
, Qt::blue
, Qt::darkBlue
, Qt::cyan
, Qt::darkCyan
, Qt::magenta
, Qt::darkMagenta
, Qt::yellow
, Qt::darkYellow
, Qt::gray
, Qt::darkGray
, Qt::lightGray
, Qt::color0
, Qt::color1
, and Qt::transparent
.
QColor
provides the static colorNames()
function which returns a QStringList containing the color names Qt knows about. The colors HSV, like RGB, has three components: 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 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
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).The HSV Color Model
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.
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. alpha-blended drawing
.The CMYK Color Model
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. alpha-blended drawing
. QPalette
, QBrush
, and QApplication::setColorSpec()
.
Nested Class Summary | |
---|---|
static class |
QColor.Spec
|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary | |
---|---|
static QColor |
black
|
static QColor |
blue
|
static QColor |
color0
|
static QColor |
color1
|
static QColor |
cyan
|
static QColor |
darkBlue
|
static QColor |
darkCyan
|
static QColor |
darkGray
|
static QColor |
darkGreen
|
static QColor |
darkMagenta
|
static QColor |
darkRed
|
static QColor |
darkYellow
|
static QColor |
gray
|
static QColor |
green
|
static QColor |
lightGray
|
static QColor |
magenta
|
static QColor |
red
|
static QColor |
transparent
|
static QColor |
white
|
static QColor |
yellow
|
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QColor()
Constructs an invalid color with the RGB value (0, 0, 0). |
|
QColor(int rgb)
Constructs a color with the value color. |
|
QColor(int r,
int g,
int b)
Constructs a color with the RGB value r, g, b, and the alpha-channel (transparency) value of a. |
|
QColor(int r,
int g,
int b,
int a)
Constructs a color with the RGB value r, g, b, and the alpha-channel (transparency) value of a. |
|
QColor(QColor color)
Constructs a color that is a copy of color. |
|
QColor(Qt.GlobalColor color)
Constructs a new color with a color value of color. |
|
QColor(java.lang.String name)
Constructs a named color in the same way as setNamedColor() using the given name. |
Method Summary | |
---|---|
int |
alpha()
Returns the alpha color component of this color. |
double |
alphaF()
Returns the alpha color component of this color. |
int |
black()
Returns the black color component of this color. |
double |
blackF()
Returns the black color component of this color. |
int |
blue()
Returns the blue color component of this color. |
double |
blueF()
Returns the blue color component of this color. |
QColor |
clone()
This method is reimplemented for internal reasons |
static java.util.List |
colorNames()
Returns a QStringList containing the color names Qt knows about. |
QColor |
convertTo(QColor.Spec colorSpec)
Creates a copy of this color in the format specified by colorSpec. |
int |
cyan()
Returns the cyan color component of this color. |
double |
cyanF()
Returns the cyan color component of this color. |
QColor |
darker()
Returns a darker (or lighter) color, but does not change this object. |
QColor |
darker(int f)
Returns a darker (or lighter) color, but does not change this object. |
static QColor |
fromCmyk(int c,
int m,
int y,
int k)
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. |
static QColor |
fromCmyk(int c,
int m,
int y,
int k,
int a)
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. |
static QColor |
fromCmykF(double c,
double m,
double y,
double k)
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. |
static QColor |
fromCmykF(double c,
double m,
double y,
double k,
double a)
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. |
static QColor |
fromHsv(int h,
int s,
int v)
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. |
static QColor |
fromHsv(int h,
int s,
int v,
int a)
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. |
static QColor |
fromHsvF(double h,
double s,
double v)
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. |
static QColor |
fromHsvF(double h,
double s,
double v,
double a)
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. |
static QColor |
fromRgb(int rgb)
Static convenience function that returns a QColor constructed from the given QRgb value rgb. |
static QColor |
fromRgb(int r,
int g,
int b)
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. |
static QColor |
fromRgb(int r,
int g,
int b,
int a)
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. |
static QColor |
fromRgba(int rgba)
Static convenience function that returns a QColor constructed from the given QRgb value rgba. |
static QColor |
fromRgbF(double r,
double g,
double b)
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. |
static QColor |
fromRgbF(double r,
double g,
double b,
double a)
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. |
int |
green()
Returns the green color component of this color. |
double |
greenF()
Returns the green color component of this color. |
int |
hue()
Returns the hue color component of this color. |
double |
hueF()
Returns the hue color component of this color. |
boolean |
isValid()
Returns true if the color is valid; otherwise returns false. |
QColor |
lighter()
Returns a lighter (or darker) color, but does not change this object. |
QColor |
lighter(int f)
Returns a lighter (or darker) color, but does not change this object. |
int |
magenta()
Returns the magenta color component of this color. |
double |
magentaF()
Returns the magenta color component of this color. |
java.lang.String |
name()
Returns the name of the color in the format "#RRGGBB"; i. |
void |
readFrom(QDataStream arg__1)
|
int |
red()
Returns the red color component of this color. |
double |
redF()
Returns the red color component of this color. |
int |
rgb()
Returns the RGB value of the color. |
int |
rgba()
Returns the RGB value of the color. |
int |
saturation()
Returns the saturation color component of this color. |
double |
saturationF()
Returns the saturation color component of this color. |
void |
setAlpha(int alpha)
Sets the alpha of this color to alpha. |
void |
setAlphaF(double alpha)
Sets the alpha of this color to alpha. |
void |
setBlue(int blue)
Sets the blue color component of this color to blue. |
void |
setBlueF(double blue)
Sets the blue color component of this color to blue. |
void |
setCmyk(int c,
int m,
int y,
int k)
Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i. |
void |
setCmyk(int c,
int m,
int y,
int k,
int a)
Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i. |
void |
setCmykF(double c,
double m,
double y,
double k)
Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i. |
void |
setCmykF(double c,
double m,
double y,
double k,
double a)
Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i. |
void |
setGreen(int green)
Sets the green color component of this color to green. |
void |
setGreenF(double green)
Sets the green color component of this color to green. |
void |
setHsv(int h,
int s,
int v)
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. |
void |
setHsv(int h,
int s,
int v,
int a)
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. |
void |
setHsvF(double h,
double s,
double v)
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. |
void |
setHsvF(double h,
double s,
double v,
double a)
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. |
void |
setNamedColor(java.lang.String name)
Sets the RGB value of this QColor to name, which may be in one of these formats: #RGB (each of R, G, and B is a single hex digit) #RRGGBB #RRRGGGBBB #RRRRGGGGBBBB 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". |
void |
setRed(int red)
Sets the red color component of this color to red. |
void |
setRedF(double red)
Sets the red color component of this color to red. |
void |
setRgb(int rgb)
Sets the RGB value to rgb, ignoring the alpha. |
void |
setRgb(int r,
int g,
int b)
Sets the RGB value to r, g, b and the alpha value to a. |
void |
setRgb(int r,
int g,
int b,
int a)
Sets the RGB value to r, g, b and the alpha value to a. |
void |
setRgba(int rgba)
Sets the RGBA value to rgba. |
void |
setRgbF(double r,
double g,
double b)
Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency). |
void |
setRgbF(double r,
double g,
double b,
double a)
Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency). |
QColor.Spec |
spec()
Returns how the color was specified. |
QColor |
toCmyk()
Creates and returns a CMYK QColor based on this color. |
QColor |
toHsv()
Creates and returns an HSV QColor based on this color. |
QColor |
toRgb()
Create and returns an RGB QColor based on this color. |
java.lang.String |
toString()
|
int |
value()
Returns the value color component of this color. |
double |
valueF()
Returns the value color component of this color. |
void |
writeTo(QDataStream arg__1)
|
int |
yellow()
Returns the yellow color component of this color. |
double |
yellowF()
Returns the yellow color component of this color. |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public static final QColor white
public static final QColor black
public static final QColor red
public static final QColor darkRed
public static final QColor green
public static final QColor darkGreen
public static final QColor blue
public static final QColor darkBlue
public static final QColor cyan
public static final QColor darkCyan
public static final QColor magenta
public static final QColor darkMagenta
public static final QColor yellow
public static final QColor darkYellow
public static final QColor gray
public static final QColor darkGray
public static final QColor lightGray
public static final QColor transparent
public static final QColor color0
public static final QColor color1
Constructor Detail |
---|
public QColor()
The alpha value of an invalid color is unspecified.
isValid()
.
public QColor(Qt.GlobalColor color)
isValid()
, and Predefined Colors
.
public QColor(QColor color)
isValid()
.
public QColor(java.lang.String name)
setNamedColor()
using the given name. The color is left invalid if the name cannot be parsed.
setNamedColor()
, name()
, and isValid()
.
public QColor(int r, int g, int b)
The color is left invalid if any of the arguments are invalid.
setRgba()
, and isValid()
.
public QColor(int r, int g, int b, int a)
The color is left invalid if any of the arguments are invalid.
setRgba()
, and isValid()
.
public QColor(int rgb)
fromRgb()
, and isValid()
.
Method Detail |
---|
public final int alpha()
setAlpha()
, alphaF()
, and Alpha-Blended Drawing
.
public final double alphaF()
setAlphaF()
, alpha()
, and Alpha-Blended Drawing
.
public final int black()
blackF()
, getCmyk(), and The CMYK Color Model
.
public final double blackF()
black()
, getCmykF(), and The CMYK Color Model
.
public final int blue()
setBlue()
, blueF()
, and getRgb().
public final double blueF()
setBlueF()
, blue()
, and getRgbF().
public final QColor convertTo(QColor.Spec colorSpec)
spec()
, toCmyk()
, toHsv()
, toRgb()
, and isValid()
.
public final int cyan()
cyanF()
, getCmyk(), and The CMYK Color Model
.
public final double cyanF()
cyan()
, getCmykF(), and The CMYK Color Model
.
public final QColor darker()
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.
lighter()
, and isValid()
.
public final QColor darker(int f)
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.
lighter()
, and isValid()
.
public final int green()
setGreen()
, greenF()
, and getRgb().
public final double greenF()
setGreenF()
, green()
, and getRgbF().
public final int hue()
hueF()
, getHsv(), and The HSV Color Model
.
public final double hueF()
hue()
, getHsvF(), and The HSV Color Model
.
public final boolean isValid()
public final QColor lighter()
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.
darker()
, and isValid()
.
public final QColor lighter(int f)
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.
darker()
, and isValid()
.
public final int magenta()
magentaF()
, getCmyk(), and The CMYK Color Model
.
public final double magentaF()
magenta()
, getCmykF(), and The CMYK Color Model
.
public final java.lang.String name()
setNamedColor()
.
public final void writeTo(QDataStream arg__1)
public final void readFrom(QDataStream arg__1)
public final int red()
setRed()
, redF()
, and getRgb().
public final double redF()
setRedF()
, red()
, and getRgbF().
public final int rgb()
setRgb()
, getRgb(), and rgba()
.
public final int rgba()
rgb()
, the alpha is not stripped. For an invalid color, the alpha value of the returned color is unspecified.
setRgba()
, and rgb()
.
public final int saturation()
saturationF()
, getHsv(), and The HSV Color Model
.
public final double saturationF()
saturation()
, getHsvF(), and The HSV Color Model
.
public final void setAlpha(int alpha)
alpha()
, alphaF()
, and Alpha-Blended Drawing
.
public final void setAlphaF(double alpha)
alphaF()
, alpha()
, and Alpha-Blended Drawing
.
public final void setBlue(int blue)
blue()
, blueF()
, and setRgb()
.
public final void setBlueF(double blue)
blueF()
, blue()
, and setRgbF()
.
public final void setCmyk(int c, int m, int y, int k)
All the values must be in the range 0-255.
setCmykF()
, and The CMYK Color Model
.
public final void setCmyk(int c, int m, int y, int k, int a)
All the values must be in the range 0-255.
setCmykF()
, and The CMYK Color Model
.
public final void setCmykF(double c, double m, double y, double k)
All the values must be in the range 0.0-1.0.
setCmyk()
, and The CMYK Color Model
.
public final void setCmykF(double c, double m, double y, double k, double a)
All the values must be in the range 0.0-1.0.
setCmyk()
, and The CMYK Color Model
.
public final void setGreen(int green)
green()
, greenF()
, and setRgb()
.
public final void setGreenF(double green)
greenF()
, green()
, and setRgbF()
.
public final void setHsv(int h, int s, int v)
The saturation, value and alpha-channel values must be in the range 0-255, and the hue value must be greater than -1.
setHsvF()
, and The HSV Color Model
.
public final void setHsv(int h, int s, int v, int a)
The saturation, value and alpha-channel values must be in the range 0-255, and the hue value must be greater than -1.
setHsvF()
, and The HSV Color Model
.
public final void setHsvF(double h, double s, double v)
All the values must be in the range 0.0-1.0.
setHsv()
, and The HSV Color Model
.
public final void setHsvF(double h, double s, double v, double a)
All the values must be in the range 0.0-1.0.
setHsv()
, and The HSV Color Model
.
public final void setNamedColor(java.lang.String name)
QColor
to name, which may be in one of these formats: Qt::GlobalColor
enums, e.g. "green" and Qt::green
does not refer to the same color.name()
, isValid()
, and allowX11ColorNames().
public final void setRed(int red)
red()
, redF()
, and setRgb()
.
public final void setRedF(double red)
redF()
, red()
, and setRgbF()
.
public final void setRgb(int r, int g, int b)
All the values must be in the range 0-255.
rgb()
, getRgb(), and setRgbF()
.
public final void setRgb(int r, int g, int b, int a)
All the values must be in the range 0-255.
rgb()
, getRgb(), and setRgbF()
.
public final void setRgb(int rgb)
public final void setRgbF(double r, double g, double b)
All values must be in the range 0.0-1.0.
rgb()
, getRgbF(), and setRgb()
.
public final void setRgbF(double r, double g, double b, double a)
All values must be in the range 0.0-1.0.
rgb()
, getRgbF(), and setRgb()
.
public final void setRgba(int rgba)
rgba()
, and rgb()
.
public final QColor.Spec spec()
Spec
, and convertTo()
.
public final QColor toCmyk()
QColor
based on this color. fromCmyk()
, convertTo()
, isValid()
, and The CMYK Color Model
.
public final QColor toHsv()
QColor
based on this color. fromHsv()
, convertTo()
, isValid()
, and The HSV Color Model
.
public final QColor toRgb()
QColor
based on this color. fromRgb()
, convertTo()
, and isValid()
.
public final int value()
valueF()
, getHsv(), and The HSV Color Model
.
public final double valueF()
value()
, getHsvF(), and The HSV Color Model
.
public final int yellow()
yellowF()
, getCmyk(), and The CMYK Color Model
.
public final double yellowF()
yellow()
, getCmykF(), and The CMYK Color Model
.
public static java.util.List colorNames()
Predefined Colors
.
public static QColor fromCmyk(int c, int m, int y, int k)
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.
toCmyk()
, fromCmykF()
, isValid()
, and The CMYK Color Model
.
public static QColor fromCmyk(int c, int m, int y, int k, int 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.
toCmyk()
, fromCmykF()
, isValid()
, and The CMYK Color Model
.
public static QColor fromCmykF(double c, double m, double y, double k)
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.
toCmyk()
, fromCmyk()
, isValid()
, and The CMYK Color Model
.
public static QColor fromCmykF(double c, double m, double y, double k, double 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.
toCmyk()
, fromCmyk()
, isValid()
, and The CMYK Color Model
.
public static QColor fromHsv(int h, int s, int v)
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.
toHsv()
, fromHsvF()
, isValid()
, and The HSV Color Model
.
public static QColor fromHsv(int h, int s, int v, int 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.
toHsv()
, fromHsvF()
, isValid()
, and The HSV Color Model
.
public static QColor fromHsvF(double h, double s, double v)
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.
toHsv()
, fromHsv()
, isValid()
, and The HSV Color Model
.
public static QColor fromHsvF(double h, double s, double v, double 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.
toHsv()
, fromHsv()
, isValid()
, and The HSV Color Model
.
public static QColor fromRgb(int r, int g, int b)
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.
toRgb()
, fromRgbF()
, and isValid()
.
public static QColor fromRgb(int r, int g, int b, int 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.
toRgb()
, fromRgbF()
, and isValid()
.
public static QColor fromRgb(int rgb)
QColor
constructed from the given QRgb value rgb. Note that 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.
fromRgba()
, fromRgbF()
, toRgb()
, and isValid()
.
public static QColor fromRgbF(double r, double g, double b)
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.
fromRgb()
, toRgb()
, and isValid()
.
public static QColor fromRgbF(double r, double g, double b, double 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.
fromRgb()
, toRgb()
, and isValid()
.
public static QColor fromRgba(int rgba)
QColor
constructed from the given QRgb value rgba. Note that unlike the fromRgb()
function, the alpha-channel specified by the given QRgb value is included.
fromRgb()
, and isValid()
.
public java.lang.String toString()
toString
in class java.lang.Object
public QColor clone()
clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |