QColor class provides colors based on RGB, HSV or CMYK values. 更多...
头: | #include <QColor> |
qmake: | QT += gui |
enum | NameFormat { HexRgb, HexArgb } |
enum | Spec { Rgb, Hsv, Cmyk, Hsl, Invalid } |
QColor () | |
QColor (Qt::GlobalColor color ) | |
QColor (int r , int g , int b , int a = 255) | |
QColor (QRgb color ) | |
QColor (QRgba64 rgba64 ) | |
QColor (const QString & name ) | |
QColor (const char * name ) | |
QColor (QLatin1String name ) | |
QColor (const QColor & color ) | |
QColor (QColor && other ) | |
int | alpha () const |
qreal | alphaF () const |
int | black () const |
qreal | blackF () const |
int | blue () const |
qreal | blueF () const |
QColor | convertTo (Spec colorSpec ) const |
int | cyan () const |
qreal | cyanF () const |
QColor | darker (int factor = 200) const |
void | getCmyk (int * c , int * m , int * y , int * k , int * a = Q_NULLPTR) |
void | getCmykF (qreal * c , qreal * m , qreal * y , qreal * k , qreal * a = Q_NULLPTR) |
void | getHsl (int * h , int * s , int * l , int * a = Q_NULLPTR) const |
void | getHslF (qreal * h , qreal * s , qreal * l , qreal * a = Q_NULLPTR) const |
void | getHsv (int * h , int * s , int * v , int * a = Q_NULLPTR) const |
void | getHsvF (qreal * h , qreal * s , qreal * v , qreal * a = Q_NULLPTR) const |
void | getRgb (int * r , int * g , int * b , int * a = Q_NULLPTR) const |
void | getRgbF (qreal * r , qreal * g , qreal * b , qreal * a = Q_NULLPTR) const |
int | green () const |
qreal | greenF () const |
int | hslHue () const |
qreal | hslHueF () const |
int | hslSaturation () const |
qreal | hslSaturationF () const |
int | hsvHue () const |
qreal | hsvHueF () const |
int | hsvSaturation () const |
qreal | hsvSaturationF () const |
int | hue () const |
qreal | hueF () const |
bool | isValid () const |
QColor | lighter (int factor = 150) const |
int | lightness () const |
qreal | lightnessF () const |
int | magenta () const |
qreal | magentaF () const |
QString | name () const |
QString | name (NameFormat format ) const |
int | red () const |
qreal | redF () const |
QRgb | rgb () const |
QRgba64 | rgba64 () const |
QRgb | rgba () const |
int | saturation () const |
qreal | saturationF () const |
void | setAlpha (int alpha ) |
void | setAlphaF (qreal alpha ) |
void | setBlue (int blue ) |
void | setBlueF (qreal blue ) |
void | setCmyk (int c , int m , int y , int k , int a = 255) |
void | setCmykF (qreal c , qreal m , qreal y , qreal k , qreal a = 1.0) |
void | setGreen (int green ) |
void | setGreenF (qreal green ) |
void | setHsl (int h , int s , int l , int a = 255) |
void | setHslF (qreal h , qreal s , qreal l , qreal a = 1.0) |
void | setHsv (int h , int s , int v , int a = 255) |
void | setHsvF (qreal h , qreal s , qreal v , qreal a = 1.0) |
void | setNamedColor (const QString & name ) |
void | setNamedColor (QLatin1String name ) |
void | setRed (int red ) |
void | setRedF (qreal red ) |
void | setRgb (int r , int g , int b , int a = 255) |
void | setRgb (QRgb rgb ) |
void | setRgba64 (QRgba64 rgba ) |
void | setRgbF (qreal r , qreal g , qreal b , qreal a = 1.0) |
void | setRgba (QRgb rgba ) |
Spec | spec () const |
QColor | toCmyk () const |
QColor | toHsl () const |
QColor | toHsv () const |
QColor | toRgb () const |
int | value () const |
qreal | valueF () const |
int | yellow () const |
qreal | yellowF () const |
operator QVariant () const | |
bool | operator!= (const QColor & color ) const |
QColor & | operator= (QColor && other ) |
QColor & | operator= (const QColor & color ) |
QColor & | operator= (Qt::GlobalColor color ) |
bool | operator== (const QColor & color ) const |
QStringList | colorNames () |
QColor | fromCmyk (int c , int m , int y , int k , int a = 255) |
QColor | fromCmykF (qreal c , qreal m , qreal y , qreal k , qreal a = 1.0) |
QColor | fromHsl (int h , int s , int l , int a = 255) |
QColor | fromHslF (qreal h , qreal s , qreal l , qreal a = 1.0) |
QColor | fromHsv (int h , int s , int v , int a = 255) |
QColor | fromHsvF (qreal h , qreal s , qreal v , qreal a = 1.0) |
QColor | fromRgb (QRgb rgb ) |
QColor | fromRgb (int r , int g , int b , int a = 255) |
QColor | fromRgba64 (ushort r , ushort g , ushort b , ushort a = USHRT_MAX) |
QColor | fromRgba64 (QRgba64 rgba64 ) |
QColor | fromRgbF (qreal r , qreal g , qreal b , qreal a = 1.0) |
QColor | fromRgba (QRgb rgba ) |
bool | isValidColor (const QString & name ) |
bool | isValidColor (QLatin1String name ) |
typedef | QRgb |
int | qAlpha (QRgb rgba ) |
uint | qAlpha (QRgba64 rgba64 ) |
int | qBlue (QRgb rgb ) |
uint | qBlue (QRgba64 rgba64 ) |
int | qGray (int r , int g , int b ) |
int | qGray (QRgb rgb ) |
int | qGreen (QRgb rgb ) |
uint | qGreen (QRgba64 rgba64 ) |
QRgb | qPremultiply (QRgb rgb ) |
QRgba64 | qPremultiply (QRgba64 rgba64 ) |
int | qRed (QRgb rgb ) |
uint | qRed (QRgba64 rgba64 ) |
QRgb | qRgb (int r , int g , int b ) |
QRgba64 | qRgba64 (quint16 r , quint16 g , quint16 b , quint16 a ) |
QRgba64 | qRgba64 (quint64 c ) |
QRgb | qRgba (int r , int g , int b , int a ) |
QRgb | qUnpremultiply (QRgb rgb ) |
QRgba64 | qUnpremultiply (QRgba64 rgba64 ) |
QDataStream & | operator<< (QDataStream & stream , const QColor & color ) |
QDataStream & | operator>> (QDataStream & stream , QColor & color ) |
QColor class provides colors based on RGB, HSV or CMYK values.
颜色通常根据 RGB (红色、绿色和蓝色) 分量指定,根据 HSV (色调、饱和度和值) 和 CMYK (青色、洋红色、黄色和黑色) 分量指定也是可能。此外,可以使用颜色名称指定颜色。颜色名称可以是任何 SVG 1.0 颜色名称。
RGB | HSV | CMYK |
---|---|---|
QColor constructor creates the color based on RGB values. To create a QColor based on either HSV or CMYK values, use the toHsv () 和 toCmyk () functions respectively. These functions return a copy of the color using the desired format. In addition the static fromRgb (), fromHsv () 和 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 () 和 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 () 和 setCmyk (). To get a lighter or darker color use the lighter () 和 darker () 函数分别。
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 () 和 cyan (). The values of the color components can also be retrieved in one go using the getRgb (), getHsv () 和 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 的绘制 section). The qRed (), qBlue () 和 qGreen () functions return the respective component of the given QRgb value, while the qRgb () 和 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 ,和 qGray () function calculates and return a gray value based on the given value.
QColor is platform and device independent. The QColormap 类把颜色映射到硬件。
一般而言,有关描绘的更多信息,见 描绘系统 文档编制。
QColor supports floating point precision and provides floating point versions of all the color components functions, e.g. getRgbF (), hueF () 和 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.
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(QColor(255, 0, 0, 127)); painter.drawRect(0, 0, width()/2, height()); // Specify semi-transparent blue painter.setBrush(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 () 和 setAlpha () functions if its value is an integer, and alphaF () 和 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 () 和 setRgba () 函数。
There are 20 predefined QColors described by the Qt::GlobalColor enum, including black, white, primary and secondary colors, darker versions of these colors and three shades of gray. QColor also recognizes a variety of color names; the static colorNames () 函数返回 QStringList color names that QColor knows about.
Additionally, the Qt::color0 , Qt::color1 and Qt::transparent colors are used for special purposes.
Qt::color0 (zero pixel value) and Qt::color1 (non-zero pixel value) are special colors for drawing in QBitmaps. Painting with Qt::color0 sets the bitmap bits to 0 (transparent; i.e., background), and painting with Qt::color1 sets the bits to 1 (opaque; i.e., foreground).
Qt::transparent is used to indicate a transparent pixel. When painting with this value, a pixel value will be used that is appropriate for the underlying pixel format in use.
The RGB model is hardware-oriented. Its representation is close to what most monitors show. In contrast, HSV represents color in a way more suited to the human perception of color. For example, the relationships "stronger than", "darker than", and "the opposite of" are easily expressed in HSV but are much harder to express in RGB.
HSV, like RGB, has three components:
Here are some examples: pure red is H=0, S=255, V=255; a dark red, moving slightly towards the magenta, could be H=350 (equivalent to -10), S=255, V=180; a grayish light red could have H about 0 (say 350-359 or 0-10), S about 50-100, and S=255.
Qt returns a hue value of -1 for achromatic colors. If you pass a hue value that is too large, Qt forces it into range. Hue 360 or 720 is treated as 0; hue 540 is treated as 180.
In addition to the standard HSV model, Qt provides an alpha-channel to feature alpha-blended drawing .
HSL is similar to HSV, however instead of the Value parameter, HSL specifies a Lightness parameter.
While the RGB and HSV color models are used for display on computer monitors, the CMYK model is used in the four-color printing process of printing presses and some hard-copy devices.
CMYK has four components, all in the range 0-255: cyan (C), magenta (M), yellow (Y) and black (K). Cyan, magenta and yellow are called subtractive colors; the CMYK color model creates color by starting with a white surface and then subtracting color by applying the appropriate components. While combining cyan, magenta and yellow gives the color black, subtracting one or more will yield any other color. When combined in various percentages, these three colors can create the entire spectrum of colors.
Mixing 100 percent of cyan, magenta and yellow does produce black, but the result is unsatisfactory since it wastes ink, increases drying time, and gives a muddy colour when printing. For that reason, black is added in professional printing to provide a solid black tone; hence the term 'four color process'.
In addition to the standard CMYK model, Qt provides an alpha-channel to feature alpha-blended drawing .
How to format the output of the name () 函数
常量 | 值 | 描述 |
---|---|---|
QColor::HexRgb
|
0
|
#RRGGBB A "#" character followed by three two-digit hexadecimal numbers (i.e.
#RRGGBB
).
|
QColor::HexArgb
|
1
|
#AARRGGBB A "#" character followed by four two-digit hexadecimal numbers (i.e.
#AARRGGBB
).
|
另请参阅 name ().
The type of color specified, either RGB, HSV, CMYK or HSL.
常量 | 值 |
---|---|
QColor::Rgb
|
1
|
QColor::Hsv
|
2
|
QColor::Cmyk
|
3
|
QColor::Hsl
|
4
|
QColor::Invalid
|
0
|
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.
另请参阅 isValid ().
这是重载函数。
构造新颜色采用颜色值 color .
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.
构造颜色采用值 color . The alpha component is ignored and set to solid.
构造颜色采用值 rgba64 .
该函数在 Qt 5.6 引入。
另请参阅 fromRgba64 ().
构造命名颜色以相同方式如 setNamedColor () 使用给定 name .
The color is left invalid if the name 无法剖析。
另请参阅 setNamedColor (), name (),和 isValid ().
构造命名颜色以相同方式如 setNamedColor () 使用给定 name .
这是重载函数。
另请参阅 setNamedColor (), name (),和 isValid ().
构造命名颜色以相同方式如 setNamedColor () 使用给定 name .
这是重载函数。
该函数在 Qt 5.8 引入。
另请参阅 setNamedColor (), name (),和 isValid ().
Constructs a color that is a copy of color .
另请参阅 isValid ().
移动拷贝构造函数。
返回此颜色的 Alpha 颜色分量。
另请参阅 setAlpha (), alphaF (),和 融合 Alpha 的绘制 .
返回此颜色的 Alpha 颜色分量。
另请参阅 setAlphaF (), alpha (),和 融合 Alpha 的绘制 .
返回此颜色的黑色分量。
另请参阅 blackF (), getCmyk (),和 CMYK 颜色模型 .
返回此颜色的黑色分量。
另请参阅 black (), getCmykF (),和 CMYK 颜色模型 .
Returns the blue color component of this color.
另请参阅 setBlue (), blueF (),和 getRgb ().
Returns the blue color component of this color.
另请参阅 setBlueF (), blue (),和 getRgbF ().
[static]
QStringList
QColor::
colorNames
()
返回 QStringList containing the color names Qt knows about.
另请参阅 预定义的颜色 .
Creates a copy of this color in the format specified by colorSpec .
另请参阅 spec (), toCmyk (), toHsv (), toRgb (),和 isValid ().
Returns the cyan color component of this color.
另请参阅 cyanF (), getCmyk (),和 CMYK 颜色模型 .
Returns the cyan color component of this color.
另请参阅 cyan (), getCmykF (),和 CMYK 颜色模型 .
Returns a darker (or lighter) color, but does not change this object.
若 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.
该函数在 Qt 4.3 引入。
[static]
QColor
QColor::
fromCmyk
(
int
c
,
int
m
,
int
y
,
int
k
,
int
a
= 255)
静态方便函数返回 QColor constructed from the given CMYK color values: c (青色), m (洋红色), y (黄色), k (黑色),和 a (alpha-channel, i.e. transparency).
所有值必须在 0-255 范围内。
另请参阅 toCmyk (), fromCmykF (), isValid (),和 CMYK 颜色模型 .
[static]
QColor
QColor::
fromCmykF
(
qreal
c
,
qreal
m
,
qreal
y
,
qreal
k
,
qreal
a
= 1.0)
这是重载函数。
静态方便函数返回 QColor constructed from the given CMYK color values: c (青色), m (洋红色), y (黄色), k (黑色),和 a (alpha-channel, i.e. transparency).
所有值必须在 0.0-1.0 范围内。
另请参阅 toCmyk (), fromCmyk (), isValid (),和 CMYK 颜色模型 .
[static]
QColor
QColor::
fromHsl
(
int
h
,
int
s
,
int
l
,
int
a
= 255)
静态方便函数返回 QColor constructed from the HSV color values, h (hue), s (saturation), l (lightness), and a (alpha-channel, i.e. transparency).
值 s , l ,和 a must all be in the range 0-255; the value of h must be in the range 0-359.
该函数在 Qt 4.6 引入。
另请参阅 toHsl (), fromHslF (),和 isValid ().
[static]
QColor
QColor::
fromHslF
(
qreal
h
,
qreal
s
,
qreal
l
,
qreal
a
= 1.0)
这是重载函数。
静态方便函数返回 QColor constructed from the HSV color values, h (hue), s (saturation), l (lightness), and a (alpha-channel, i.e. transparency).
所有值必须在 0.0-1.0 范围内。
该函数在 Qt 4.6 引入。
另请参阅 toHsl (), fromHsl (),和 isValid ().
[static]
QColor
QColor::
fromHsv
(
int
h
,
int
s
,
int
v
,
int
a
= 255)
静态方便函数返回 QColor constructed from the HSV color values, h (hue), s (saturation), v (value), and a (alpha-channel, i.e. transparency).
值 s , v ,和 a must all be in the range 0-255; the value of h must be in the range 0-359.
另请参阅 toHsv (), fromHsvF (), isValid (),和 HSV 颜色模型 .
[static]
QColor
QColor::
fromHsvF
(
qreal
h
,
qreal
s
,
qreal
v
,
qreal
a
= 1.0)
这是重载函数。
静态方便函数返回 QColor constructed from the HSV color values, h (hue), s (saturation), v (value), and a (alpha-channel, i.e. transparency).
所有值必须在 0.0-1.0 范围内。
另请参阅 toHsv (), fromHsv (), isValid (),和 HSV 颜色模型 .
[static]
QColor
QColor::
fromRgb
(
QRgb
rgb
)
静态方便函数返回 QColor constructed from the given QRgb 值 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 值。
另请参阅 fromRgba (), fromRgbF (), toRgb (),和 isValid ().
[static]
QColor
QColor::
fromRgb
(
int
r
,
int
g
,
int
b
,
int
a
= 255)
静态方便函数返回 QColor constructed from the RGB color values, r (red), g (green), b (blue), and a (alpha-channel, i.e. transparency).
所有值必须在 0-255 范围内。
另请参阅 toRgb (), fromRgba64 (), fromRgbF (),和 isValid ().
[static]
QColor
QColor::
fromRgba64
(
ushort
r
,
ushort
g
,
ushort
b
,
ushort
a
= USHRT_MAX)
静态方便函数返回 QColor constructed from the RGBA64 color values, r (red), g (green), b (blue), and a (alpha-channel, i.e. transparency).
该函数在 Qt 5.6 引入。
另请参阅 fromRgb (), fromRgbF (), toRgb (),和 isValid ().
[static]
QColor
QColor::
fromRgba64
(
QRgba64
rgba64
)
静态方便函数返回 QColor constructed from the given QRgba64 值 rgba64 .
该函数在 Qt 5.6 引入。
另请参阅 fromRgb (), fromRgbF (), toRgb (),和 isValid ().
[static]
QColor
QColor::
fromRgbF
(
qreal
r
,
qreal
g
,
qreal
b
,
qreal
a
= 1.0)
静态方便函数返回 QColor constructed from the RGB color values, r (red), g (green), b (blue), and a (alpha-channel, i.e. transparency).
所有值必须在 0.0-1.0 范围内。
另请参阅 fromRgb (), fromRgba64 (), toRgb (),和 isValid ().
[static]
QColor
QColor::
fromRgba
(
QRgb
rgba
)
静态方便函数返回 QColor constructed from the given QRgb 值 rgba .
不像 fromRgb () function, the alpha-channel specified by the given QRgb value is included.
另请参阅 fromRgb (), fromRgba64 (),和 isValid ().
Sets the contents pointed to by c , m , y , k ,和 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 () 和 alpha () 函数。
Sets the contents pointed to by c , m , y , k ,和 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 () 和 alphaF () 函数。
另请参阅 setCmykF () 和 CMYK 颜色模型 .
Sets the contents pointed to by h , s , l ,和 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 () 和 alpha () 函数。
该函数在 Qt 4.6 引入。
另请参阅 setHsl ().
Sets the contents pointed to by h , s , l ,和 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 () 和 alphaF () 函数。
该函数在 Qt 4.6 引入。
另请参阅 setHsl ().
Sets the contents pointed to by h , s , v ,和 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 () 和 alpha () 函数。
Sets the contents pointed to by h , s , v ,和 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 () 和 alphaF () 函数。
Sets the contents pointed to by r , g , b ,和 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 () 和 alpha () 函数。
Sets the contents pointed to by r , g , b ,和 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 () 和 alphaF () 函数。
返回此颜色的绿色分量。
另请参阅 setGreen (), greenF (),和 getRgb ().
返回此颜色的绿色分量。
另请参阅 setGreenF (), green (),和 getRgbF ().
返回此颜色的色相颜色分量。
该函数在 Qt 4.6 引入。
返回此颜色的色相颜色分量。
该函数在 Qt 4.6 引入。
Returns the saturation color component of this color.
该函数在 Qt 4.6 引入。
另请参阅 saturationF (), getHsv (),和 HSV 颜色模型 .
Returns the saturation color component of this color.
该函数在 Qt 4.6 引入。
另请参阅 saturationF () 和 getHslF ().
返回此颜色的色相颜色分量。
另请参阅 hueF (), getHsv (),和 HSV 颜色模型 .
返回此颜色的色相颜色分量。
另请参阅 hue (), getHsvF (),和 HSV 颜色模型 .
Returns the saturation color component of this color.
另请参阅 saturationF (), getHsv (),和 HSV 颜色模型 .
Returns the saturation color component of this color.
另请参阅 saturation (), getHsvF (),和 HSV 颜色模型 .
返回此颜色的色相颜色分量。
The color is implicitly converted to HSV.
另请参阅 hsvHue (), hueF (), getHsv (),和 HSV 颜色模型 .
返回此颜色的色相颜色分量。
The color is implicitly converted to HSV.
另请参阅 hsvHueF (), hue (), getHsvF (),和 HSV 颜色模型 .
返回
true
若颜色有效;否则返回
false
.
[static]
bool
QColor::
isValidColor
(const
QString
&
name
)
返回
true
若
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 ().
该函数在 Qt 4.7 引入。
另请参阅 setNamedColor ().
[static]
bool
QColor::
isValidColor
(
QLatin1String
name
)
这是重载函数。
该函数在 Qt 5.8 引入。
Returns a lighter (or darker) color, but does not change this object.
若 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.
该函数在 Qt 4.3 引入。
Returns the lightness color component of this color.
该函数在 Qt 4.6 引入。
另请参阅 lightnessF () 和 getHsl ().
Returns the lightness color component of this color.
该函数在 Qt 4.6 引入。
Returns the magenta color component of this color.
另请参阅 magentaF (), getCmyk (),和 CMYK 颜色模型 .
Returns the magenta color component of this color.
另请参阅 magenta (), getCmykF (),和 CMYK 颜色模型 .
Returns the name of the color in the format "#RRGGBB"; i.e. a "#" character followed by three two-digit hexadecimal numbers.
另请参阅 setNamedColor ().
Returns the name of the color in the specified format .
该函数在 Qt 5.2 引入。
另请参阅 setNamedColor () 和 NameFormat .
返回此颜色的红色分量。
另请参阅 setRed (), redF (),和 getRgb ().
返回此颜色的红色分量。
另请参阅 setRedF (), red (),和 getRgbF ().
Returns the RGB value of the color. The alpha value is opaque.
另请参阅 setRgb (), getRgb (),和 rgba ().
Returns the RGB64 value of the color, including its alpha.
For an invalid color, the alpha value of the returned color is unspecified.
该函数在 Qt 5.6 引入。
另请参阅 setRgba64 (), rgba (),和 rgb ().
返回颜色的 RGB 值,包括其 Alpha。
For an invalid color, the alpha value of the returned color is unspecified.
另请参阅 setRgba (), rgb (),和 rgba64 ().
Returns the saturation color component of this color.
The color is implicitly converted to HSV.
另请参阅 hsvSaturation (), saturationF (), getHsv (),和 HSV 颜色模型 .
Returns the saturation color component of this color.
The color is implicitly converted to HSV.
另请参阅 hsvSaturationF (), saturation (), getHsvF (),和 HSV 颜色模型 .
Sets the alpha of this color to alpha . Integer alpha is specified in the range 0-255.
另请参阅 alpha (), alphaF (),和 融合 Alpha 的绘制 .
Sets the alpha of this color to alpha . qreal alpha is specified in the range 0.0-1.0.
另请参阅 alphaF (), alpha (),和 融合 Alpha 的绘制 .
Sets the blue color component of this color to blue . Integer components are specified in the range 0-255.
另请参阅 blue (), blueF (),和 setRgb ().
Sets the blue color component of this color to blue . Float components are specified in the range 0.0-1.0.
另请参阅 blueF (), blue (),和 setRgbF ().
将颜色设为 CMYK 值, c (青色), m (洋红色), y (黄色), k (黑色),和 a (alpha-channel, i.e. transparency).
所有值必须在 0-255 范围内。
另请参阅 getCmyk (), setCmykF (),和 CMYK 颜色模型 .
这是重载函数。
将颜色设为 CMYK 值, c (青色), m (洋红色), y (黄色), k (黑色),和 a (alpha-channel, i.e. transparency).
所有值必须在 0.0-1.0 范围内。
另请参阅 getCmykF (), setCmyk (),和 CMYK 颜色模型 .
Sets the green color component of this color to green . Integer components are specified in the range 0-255.
另请参阅 green (), greenF (),和 setRgb ().
Sets the green color component of this color to green . Float components are specified in the range 0.0-1.0.
另请参阅 greenF (), green (),和 setRgbF ().
Sets a HSL color value; h 是色相, s 是饱和度, l 是明度和 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.
该函数在 Qt 4.6 引入。
设置 HSL (色相/饱和度/明度) 颜色明度; h 是色相, s 是饱和度, l 是明度和 a is the alpha component of the HSL color.
所有值必须在 0.0-1.0 范围内。
该函数在 Qt 4.6 引入。
设置 HSV (色相/饱和度/值) 颜色值; h 是色相, s 是饱和度, v 是值和 a 是 HSV (色相/饱和度/值) 颜色的 Alpha 分量。
The saturation, value and alpha-channel values must be in the range 0-255, and the hue value must be greater than -1.
另请参阅 getHsv (), setHsvF (),和 HSV 颜色模型 .
设置 HSV (色相/饱和度/值) 颜色值; h 是色相, s 是饱和度, v 是值和 a 是 HSV (色相/饱和度/值) 颜色的 Alpha 分量。
所有值必须在 0.0-1.0 范围内。
另请参阅 getHsvF (), setHsv (),和 HSV 颜色模型 .
设置 RGB 值为此 QColor to name ,可能是这些格式之一:
transparent
- 表示缺乏颜色。
颜色无效若 name 无法剖析。
另请参阅 QColor (), name (),和 isValid ().
这是重载函数。
该函数在 Qt 5.8 引入。
Sets the red color component of this color to red . Integer components are specified in the range 0-255.
另请参阅 red (), redF (),和 setRgb ().
Sets the red color component of this color to red . Float components are specified in the range 0.0-1.0.
另请参阅 redF (), red (),和 setRgbF ().
将 RGB 值设为 r , g , b and the alpha value to a .
所有值必须在 0-255 范围内。
另请参阅 rgb (), getRgb (),和 setRgbF ().
这是重载函数。
将 RGB 值设为 rgb . The alpha value is set to opaque.
把 RGB64 值设置为 rgba ,包括其 Alpha。
该函数在 Qt 5.6 引入。
Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency).
All values must be in the range 0.0-1.0.
另请参阅 rgb (), getRgbF (),和 setRgb ().
将 RGB 值设为 rgba ,包括其 Alpha。
另请参阅 rgba (), rgb (),和 setRgba64 ().
返回如何指定颜色。
Creates and returns a CMYK QColor based on this color.
另请参阅 fromCmyk (), convertTo (), isValid (),和 CMYK 颜色模型 .
Creates and returns an HSL QColor based on this color.
另请参阅 fromHsl (), convertTo (),和 isValid ().
Creates and returns an HSV QColor based on this color.
另请参阅 fromHsv (), convertTo (), isValid (),和 HSV 颜色模型 .
Create and returns an RGB QColor based on this color.
另请参阅 fromRgb (), convertTo (),和 isValid ().
Returns the value color component of this color.
另请参阅 valueF (), getHsv (),和 HSV 颜色模型 .
Returns the value color component of this color.
另请参阅 value (), getHsvF (),和 HSV 颜色模型 .
Returns the yellow color component of this color.
另请参阅 yellowF (), getCmyk (),和 CMYK 颜色模型 .
Returns the yellow color component of this color.
另请参阅 yellow (), getCmykF (),和 CMYK 颜色模型 .
Returns the color as a QVariant
返回
true
if this color has a different RGB and alpha values from
color
;否则返回
false
.
移动赋值运算符。
赋值副本为 color to this color, and returns a reference to it.
这是重载函数。
赋值副本为 color and returns a reference to this color.
返回
true
if this color has the same RGB and alpha values as
color
;否则返回
false
.
格式为 #AARRGGBB 的 ARGB 四元组,相当于无符号整数。
The type also holds a value for the alpha-channel. The default alpha channel is
ff
, i.e opaque. For more information, see the
融合 Alpha 的绘制
章节。
另请参阅 QColor::rgb () 和 QColor::rgba ().
Returns the alpha component of the ARGB quadruplet rgba .
另请参阅 qRgb () 和 QColor::alpha ().
Returns the alpha component of rgba64 as an 8-bit value.
该函数在 Qt 5.6 引入。
另请参阅 QRgba64::alpha8 () 和 QColor::alpha ().
Returns the blue component of the ARGB quadruplet rgb .
另请参阅 qRgb () 和 QColor::blue ().
Returns the blue component of rgba64 as an 8-bit value.
该函数在 Qt 5.6 引入。
另请参阅 QRgba64::blue8 () 和 QColor::blue ().
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.
这是重载函数。
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.
Returns the green component of the ARGB quadruplet rgb .
另请参阅 qRgb () 和 QColor::green ().
Returns the green component of rgba64 as an 8-bit value.
该函数在 Qt 5.6 引入。
另请参阅 QRgba64::green8 () 和 QColor::green ().
Converts an unpremultiplied ARGB quadruplet rgb into a premultiplied ARGB quadruplet.
该函数在 Qt 5.3 引入。
另请参阅 qUnpremultiply ().
Converts an unpremultiplied QRgba64 quadruplet rgba64 into a premultiplied QRgba64 四元组。
该函数在 Qt 5.6 引入。
另请参阅 QRgba64::premultiplied () 和 qUnpremultiply ().
Returns the red component of the ARGB quadruplet rgb .
另请参阅 qRgb () 和 QColor::red ().
Returns the red component of rgba64 as an 8-bit value.
该函数在 Qt 5.6 引入。
另请参阅 QRgba64::red8 () 和 QColor::red ().
Returns the ARGB quadruplet (255, r , g , b ).
另请参阅 qRgba (), qRed (), qGreen (),和 qBlue ().
返回 QRgba64 quadruplet ( r , g , b , a ).
该函数在 Qt 5.6 引入。
另请参阅 qRgba ().
返回 c 作为 QRgba64 struct.
该函数在 Qt 5.6 引入。
另请参阅 qRgba ().
返回 ARGB 四元组 ( a , r , g , b ).
另请参阅 qRgb (), qRed (), qGreen (),和 qBlue ().
转换预乘 ARGB 四元组 rgb into an unpremultiplied ARGB quadruplet.
该函数在 Qt 5.3 引入。
另请参阅 qPremultiply ().
Converts a premultiplied QRgba64 quadruplet rgba64 into an unpremultiplied QRgba64 四元组。
该函数在 Qt 5.6 引入。
另请参阅 QRgba64::unpremultiplied () 和 qPremultiply ().
写入 color 到 stream .
另请参阅 序列化 Qt 数据类型 .
读取 color 从 stream .
另请参阅 序列化 Qt 数据类型 .