def
__eq__
(c)
def
__ne__
(c)
def
__reduce__
()
def
__repr__
()
def
__setstate__
(arg__1)
def
__str__
()
def
alpha
()
def
alphaF
()
def
black
()
def
blackF
()
def
blue
()
def
blueF
()
def
convertTo
(colorSpec)
def
cyan
()
def
cyanF
()
def
dark
([f=200])
def
darker
([f=200])
def
getCmyk
(c, m, y, k[, a=None])
def
getCmykF
(c, m, y, k[, a=None])
def
getHsl
()
def
getHslF
()
def
getHsv
()
def
getHsvF
()
def
getRgb
()
def
getRgbF
()
def
green
()
def
greenF
()
def
hslHue
()
def
hslHueF
()
def
hslSaturation
()
def
hslSaturationF
()
def
hsvHue
()
def
hsvHueF
()
def
hsvSaturation
()
def
hsvSaturationF
()
def
hue
()
def
hueF
()
def
isValid
()
def
light
([f=150])
def
lighter
([f=150])
def
lightness
()
def
lightnessF
()
def
magenta
()
def
magentaF
()
def
name
()
def
name
(format)
def
operator=
(color)
def
red
()
def
redF
()
def
rgb
()
def
rgba
()
def
saturation
()
def
saturationF
()
def
setAlpha
(alpha)
def
setAlphaF
(alpha)
def
setBlue
(blue)
def
setBlueF
(blue)
def
setCmyk
(c, m, y, k[, a=255])
def
setCmykF
(c, m, y, k[, a=1.0])
def
setGreen
(green)
def
setGreenF
(green)
def
setHsl
(h, s, l[, a=255])
def
setHslF
(h, s, l[, a=1.0])
def
setHsv
(h, s, v[, a=255])
def
setHsvF
(h, s, v[, a=1.0])
def
setNamedColor
(name)
def
setRed
(red)
def
setRedF
(red)
def
setRgb
(r, g, b[, a=255])
def
setRgb
(rgb)
def
setRgbF
(r, g, b[, a=1.0])
def
setRgba
(rgba)
def
spec
()
def
toCmyk
()
def
toExtendedRgb
()
def
toHsl
()
def
toHsv
()
def
toRgb
()
def
toTuple
()
def
value
()
def
valueF
()
def
yellow
()
def
yellowF
()
def
colorNames
()
def
fromCmyk
(c, m, y, k[, a=255])
def
fromCmykF
(c, m, y, k[, a=1.0])
def
fromHsl
(h, s, l[, a=255])
def
fromHslF
(h, s, l[, a=1.0])
def
fromHsv
(h, s, v[, a=255])
def
fromHsvF
(h, s, v[, a=1.0])
def
fromRgb
(r, g, b[, a=255])
def
fromRgb
(rgb)
def
fromRgbF
(r, g, b[, a=1.0])
def
fromRgba64
(r, g, b[, a=USHRT_MAX])
def
fromRgba
(rgba)
def
isValidColor
(name)
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.
RGB
HSV
CMYK
![]()
![]()
![]()
QColorconstructor creates the color based on RGB values. To create aQColorbased on either HSV or CMYK values, use thetoHsv()andtoCmyk()functions respectively. These functions return a copy of the color using the desired format. In addition the staticfromRgb(),fromHsv()andfromCmyk()functions create colors from the specified values. Alternatively, a color can be converted to any of the three formats using theconvertTo()function (returning a copy of the color in the desired format), or any of thesetRgb(),setHsv()andsetCmyk()functions altering this color’s format. Thespec()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. Thename()function returns the name of the color in the format “#RRGGBB”. Colors can also be set usingsetRgb(),setHsv()andsetCmyk(). To get a lighter or darker color use thelighter()anddarker()functions respectively.
isValid()function indicates whether aQColoris legal at all. For example, a RGB color with RGB values out of range is illegal. For performance reasons,QColormostly 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()andcyan(). The values of the color components can also be retrieved in one go using thegetRgb(),getHsv()andgetCmyk()functions. Using the RGB color model, the color components can in addition be accessed withrgb().There are several related non-members:
QRgbis 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 theAlpha-Blended 绘制section). TheqRed(),qBlue()andqGreen()functions return the respective component of the givenQRgbvalue, while theqRgb()andqRgba()functions create and return theQRgbtriplet based on the given component values. Finally, theqAlpha()function returns the alpha component of the providedQRgb,和qGray()function calculates and return a gray value based on the given value.
QColoris platform and device independent. TheQColormap类把颜色映射到硬件。For more information about painting in general, see the 描绘系统 文档编制。
QColorsupports floating point precision and provides floating point versions of all the color components functions, e.g.getRgbF(),hueF()andfromCmykF(). 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 thegetRgbF()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.
QColoralso 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, self.width()/2, self.height()) # Specify semi-transparent blue painter.setBrush(QColor(0, 0, 255, 127)) painter.drawRect(0, 0, self.width(), self.height()/2)The code above produces the following output:
![]()
The alpha channel of a color can be retrieved and set using the
alpha()andsetAlpha()functions if its value is an integer, andalphaF()andsetAlphaF()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 thergba()andsetRgba()函数。
There are 20 predefined
QColorobjects in theQColorConstantsnamespace, including black, white, primary and secondary colors, darker versions of these colors, and three shades of gray. Furthermore, theQColorConstants::Svgnamespace definesQColorobjects for the standard SVG color keyword names .![]()
QColorConstants::Color0,QColorConstants::Color1andQColorConstants::Transparentcolors are used for special purposes.
QColorConstants::Color0(zero pixel value) andQColorConstants::Color1(non-zero pixel value) are special colors for drawing in QBitmaps. Painting withQColorConstants::Color0sets the bitmap bits to 0 (transparent; i.e., background), and painting with c{QColorConstants::Color1} sets the bits to 1 (opaque; i.e., foreground).
QColorConstants::Transparentis 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.For historical reasons, the 20 predefined colors are also available in the
GlobalColorenumeration.最后,
QColorrecognizes a variety of color names (as strings); the staticcolorNames()function returns aQStringListcolor names thatQColorknows about.
The extended RGB color model, also known as the scRGB color space, is the same the RGB color model except it allows values under 0.0, and over 1.0. This makes it possible to represent colors that would otherwise be outside the range of the RGB colorspace but still use the same values for colors inside the RGB colorspace.
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:
H, for hue, is in the range 0 to 359 if the color is chromatic (not gray), or meaningless if it is gray. It represents degrees on the color wheel familiar to most people. Red is 0 (degrees), green is 120, and blue is 240.
![]()
S, for saturation, is in the range 0 to 255, and the bigger it is, the stronger the color is. Grayish colors have saturation near 0; very strong colors have saturation near 255.
![]()
V, for value, is in the range 0 to 255 and represents lightness or brightness of the color. 0 is black; 255 is as far from black as possible.
![]()
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 which maps somewhat differently to the brightness of the color.
Similarly, the HSL saturation value is not in general the same as the HSV saturation value for the same color.
hslSaturation()provides the color’s HSL saturation value, whilesaturation()andhsvSaturation()provides the HSV saturation value.The hue value is defined to be the same in HSL and HSV.
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.
QColor
¶
QColor(spec, a1, a2, a3, a4[, a5=0])
QColor(arg__1)
QColor(color)
QColor(color)
QColor(name)
QColor(r, g, b[, a=255])
QColor(rgb)
- param a5
ushort- param g
int- param name
unicode
- param arg__1
object
- param spec
Spec- param color
GlobalColor- param r
int- param a
int- param a1
ushort- param b
int- param a2
ushort- param a3
ushort- param a4
ushort- param rgb
long
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.
另请参阅
这是重载函数。
构造新颜色采用颜色值
color
.
另请参阅
isValid()
Predefined
Colors
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.
PySide2.QtGui.QColor.
Spec
¶
The type of color specified, either RGB, extended RGB, HSV, CMYK or HSL.
|
常量 |
描述 |
|---|---|
|
QColor.Rgb |
|
|
QColor.Hsv |
|
|
QColor.Cmyk |
|
|
QColor.Hsl |
|
|
QColor.ExtendedRgb |
|
|
QColor.Invalid |
另请参阅
PySide2.QtGui.QColor.
NameFormat
¶
How to format the output of the
name()
function
|
常量 |
描述 |
|---|---|
|
QColor.HexRgb |
#RRGGBB A “#” character followed by three two-digit hexadecimal numbers (i.e.
|
|
QColor.HexArgb |
#AARRGGBB A “#” character followed by four two-digit hexadecimal numbers (i.e.
|
另请参阅
PySide2.QtGui.QColor.
__reduce__
(
)
¶
PyObject
PySide2.QtGui.QColor.
__repr__
(
)
¶
PyObject
PySide2.QtGui.QColor.
__setstate__
(
arg__1
)
¶
arg__1
–
PyObject
PyObject
PySide2.QtGui.QColor.
__str__
(
)
¶
PyObject
PySide2.QtGui.QColor.
alpha
(
)
¶
int
返回此颜色的 Alpha 颜色分量。
另请参阅
setAlpha()
alphaF()
Alpha-Blended
绘制
PySide2.QtGui.QColor.
alphaF
(
)
¶
qreal
返回此颜色的 Alpha 颜色分量。
另请参阅
setAlphaF()
alpha()
Alpha-Blended
绘制
PySide2.QtGui.QColor.
black
(
)
¶
int
Returns the black color component of this color.
PySide2.QtGui.QColor.
blackF
(
)
¶
qreal
Returns the black color component of this color.
另请参阅
black()
getCmykF()
CMYK
Color
Model
PySide2.QtGui.QColor.
blue
(
)
¶
int
Returns the blue color component of this color.
PySide2.QtGui.QColor.
blueF
(
)
¶
qreal
Returns the blue color component of this color.
另请参阅
PySide2.QtGui.QColor.
colorNames
(
)
¶
字符串列表
返回
QStringList
containing the color names Qt knows about.
另请参阅
Predefined
Colors
PySide2.QtGui.QColor.
convertTo
(
colorSpec
)
¶
Creates a copy of
this
color in the format specified by
colorSpec
.
PySide2.QtGui.QColor.
cyan
(
)
¶
int
Returns the cyan color component of this color.
PySide2.QtGui.QColor.
cyanF
(
)
¶
qreal
Returns the cyan color component of this color.
另请参阅
cyan()
getCmykF()
CMYK
Color
Model
PySide2.QtGui.QColor.
dark
(
[
f=200
]
)
¶
f
–
int
注意
此函数被弃用。
Use darker(
factor
) 取而代之。
PySide2.QtGui.QColor.
darker
(
[
f=200
]
)
¶
f
–
int
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 color to HSV, divides the value (V) component by
factor
and converts the color back to it’s original color spec.
PySide2.QtGui.QColor.
fromCmyk
(
c
,
m
,
y
,
k
[
,
a=255
]
)
¶
c
–
int
m
–
int
y
–
int
k
–
int
a
–
int
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.
另请参阅
toCmyk()
fromCmykF()
isValid()
CMYK
Color
Model
PySide2.QtGui.QColor.
fromCmykF
(
c
,
m
,
y
,
k
[
,
a=1.0
]
)
¶
c
–
qreal
m
–
qreal
y
–
qreal
k
–
qreal
a
–
qreal
这是重载函数。
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.
另请参阅
toCmyk()
fromCmyk()
isValid()
CMYK
Color
Model
PySide2.QtGui.QColor.
fromHsl
(
h
,
s
,
l
[
,
a=255
]
)
¶
h
–
int
s
–
int
l
–
int
a
–
int
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).
值
s
,
l
,和
a
must all be in the range 0-255; the value of
h
must be in the range 0-359.
另请参阅
toHsl()
fromHslF()
isValid()
HSL
Color
Model
PySide2.QtGui.QColor.
fromHslF
(
h
,
s
,
l
[
,
a=1.0
]
)
¶
h
–
qreal
s
–
qreal
l
–
qreal
a
–
qreal
这是重载函数。
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.
PySide2.QtGui.QColor.
fromHsv
(
h
,
s
,
v
[
,
a=255
]
)
¶
h
–
int
s
–
int
v
–
int
a
–
int
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).
值
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
Color
Model
PySide2.QtGui.QColor.
fromHsvF
(
h
,
s
,
v
[
,
a=1.0
]
)
¶
h
–
qreal
s
–
qreal
v
–
qreal
a
–
qreal
这是重载函数。
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.
PySide2.QtGui.QColor.
fromRgb
(
rgb
)
¶
rgb – long
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
值。
PySide2.QtGui.QColor.
fromRgb
(
r
,
g
,
b
[
,
a=255
]
)
¶
r
–
int
g
–
int
b
–
int
a
–
int
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.
PySide2.QtGui.QColor.
fromRgbF
(
r
,
g
,
b
[
,
a=1.0
]
)
¶
r
–
qreal
g
–
qreal
b
–
qreal
a
–
qreal
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
.
PySide2.QtGui.QColor.
fromRgba
(
rgba
)
¶
rgba – long
Static convenience function that returns a
QColor
constructed from the given
QRgb
value
rgba
.
不像
fromRgb()
function, the alpha-channel specified by the given
QRgb
value is included.
PySide2.QtGui.QColor.
fromRgba64
(
r
,
g
,
b
[
,
a=USHRT_MAX
]
)
¶
r
–
ushort
g
–
ushort
b
–
ushort
a
–
ushort
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).
PySide2.QtGui.QColor.
getCmyk
(
c
,
m
,
y
,
k
[
,
a=None
]
)
¶
c
–
int
m
–
int
y
–
int
k
–
int
a
–
int
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()
and
alpha()
函数。
另请参阅
setCmyk()
CMYK
Color
Model
PySide2.QtGui.QColor.
getCmykF
(
c
,
m
,
y
,
k
[
,
a=None
]
)
¶
c
–
qreal
m
–
qreal
y
–
qreal
k
–
qreal
a
–
qreal
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()
and
alphaF()
函数。
另请参阅
setCmykF()
CMYK
Color
Model
PySide2.QtGui.QColor.
getHsl
(
)
¶
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()
and
alpha()
函数。
PySide2.QtGui.QColor.
getHslF
(
)
¶
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()
and
alphaF()
函数。
PySide2.QtGui.QColor.
getHsv
(
)
¶
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()
and
alpha()
函数。
另请参阅
setHsv()
HSV
Color
Model
PySide2.QtGui.QColor.
getHsvF
(
)
¶
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()
and
alphaF()
函数。
另请参阅
setHsv()
HSV
Color
Model
PySide2.QtGui.QColor.
getRgb
(
)
¶
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()
and
alpha()
函数。
PySide2.QtGui.QColor.
getRgbF
(
)
¶
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()
and
alphaF()
函数。
PySide2.QtGui.QColor.
green
(
)
¶
int
Returns the green color component of this color.
另请参阅
PySide2.QtGui.QColor.
greenF
(
)
¶
qreal
Returns the green color component of this color.
另请参阅
PySide2.QtGui.QColor.
hslHue
(
)
¶
int
Returns the HSL hue color component of this color.
PySide2.QtGui.QColor.
hslHueF
(
)
¶
qreal
Returns the HSL hue color component of this color.
PySide2.QtGui.QColor.
hslSaturation
(
)
¶
int
Returns the HSL saturation color component of this color.
另请参阅
hslSaturationF()
hsvSaturation()
getHsl()
HSL
Color
Model
PySide2.QtGui.QColor.
hslSaturationF
(
)
¶
qreal
Returns the HSL saturation color component of this color.
另请参阅
hslSaturation()
hsvSaturationF()
getHslF()
HSL
Color
Model
PySide2.QtGui.QColor.
hsvHue
(
)
¶
int
Returns the HSV hue color component of this color.
PySide2.QtGui.QColor.
hsvHueF
(
)
¶
qreal
Returns the hue color component of this color.
PySide2.QtGui.QColor.
hsvSaturation
(
)
¶
int
Returns the HSV saturation color component of this color.
另请参阅
saturationF()
hslSaturation()
getHsv()
HSV
Color
Model
PySide2.QtGui.QColor.
hsvSaturationF
(
)
¶
qreal
Returns the HSV saturation color component of this color.
另请参阅
saturation()
hslSaturationF()
getHsvF()
HSV
Color
Model
PySide2.QtGui.QColor.
hue
(
)
¶
int
Returns the HSV hue color component of this color.
The color is implicitly converted to HSV.
PySide2.QtGui.QColor.
hueF
(
)
¶
qreal
Returns the HSV hue color component of this color.
The color is implicitly converted to HSV.
PySide2.QtGui.QColor.
isValid
(
)
¶
bool
返回
true
if the color is valid; otherwise returns
false
.
PySide2.QtGui.QColor.
isValidColor
(
name
)
¶
name – unicode
bool
PySide2.QtGui.QColor.
light
(
[
f=150
]
)
¶
f
–
int
注意
此函数被弃用。
Use lighter(
factor
) 取而代之。
PySide2.QtGui.QColor.
lighter
(
[
f=150
]
)
¶
f
–
int
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 color to HSV, multiplies the value (V) component by
factor
and converts the color back to it’s original color spec.
PySide2.QtGui.QColor.
lightness
(
)
¶
int
Returns the lightness color component of this color.
另请参阅
PySide2.QtGui.QColor.
lightnessF
(
)
¶
qreal
Returns the lightness color component of this color.
PySide2.QtGui.QColor.
magenta
(
)
¶
int
Returns the magenta color component of this color.
另请参阅
magentaF()
getCmyk()
CMYK
Color
Model
PySide2.QtGui.QColor.
magentaF
(
)
¶
qreal
Returns the magenta color component of this color.
另请参阅
magenta()
getCmykF()
CMYK
Color
Model
PySide2.QtGui.QColor.
name
(
)
¶
unicode
Returns the name of the color in the format “#RRGGBB”; i.e. a “#” character followed by three two-digit hexadecimal numbers.
另请参阅
PySide2.QtGui.QColor.
name
(
format
)
¶
format
–
NameFormat
unicode
Returns the name of the color in the specified
format
.
另请参阅
setNamedColor()
NameFormat
PySide2.QtGui.QColor.
__ne__
(
c
)
¶
c
–
QColor
bool
返回
true
if this color has a different RGB and alpha values from
color
;否则返回
false
.
PySide2.QtGui.QColor.operator=(color)
color
–
GlobalColor
这是重载函数。
赋值副本为
color
and returns a reference to this color.
PySide2.QtGui.QColor.
__eq__
(
c
)
¶
c
–
QColor
bool
返回
true
if this color has the same RGB and alpha values as
color
;否则返回
false
.
PySide2.QtGui.QColor.
red
(
)
¶
int
Returns the red color component of this color.
PySide2.QtGui.QColor.
redF
(
)
¶
qreal
Returns the red color component of this color.
PySide2.QtGui.QColor.
rgb
(
)
¶
long
Returns the RGB value of the color. The alpha value is opaque.
PySide2.QtGui.QColor.
rgba
(
)
¶
long
Returns the RGB value of the color, including its alpha.
For an invalid color, the alpha value of the returned color is unspecified.
PySide2.QtGui.QColor.
saturation
(
)
¶
int
Returns the HSV saturation color component of this color.
The color is implicitly converted to HSV.
另请参阅
hsvSaturation()
hslSaturation()
saturationF()
getHsv()
HSV
Color
Model
PySide2.QtGui.QColor.
saturationF
(
)
¶
qreal
Returns the HSV saturation color component of this color.
The color is implicitly converted to HSV.
另请参阅
hsvSaturationF()
hslSaturationF()
saturation()
getHsvF()
HSV
Color
Model
PySide2.QtGui.QColor.
setAlpha
(
alpha
)
¶
alpha
–
int
Sets the alpha of this color to
alpha
. Integer alpha is specified in the range 0-255.
PySide2.QtGui.QColor.
setAlphaF
(
alpha
)
¶
alpha
–
qreal
Sets the alpha of this color to
alpha
. qreal alpha is specified in the range 0.0-1.0.
PySide2.QtGui.QColor.
setBlue
(
blue
)
¶
blue
–
int
Sets the blue color component of this color to
blue
. Integer components are specified in the range 0-255.
PySide2.QtGui.QColor.
setBlueF
(
blue
)
¶
blue
–
qreal
Sets the blue color component of this color to
blue
。若
blue
lies outside the 0.0-1.0 range, the color model will be changed to
ExtendedRgb
.
PySide2.QtGui.QColor.
setCmyk
(
c
,
m
,
y
,
k
[
,
a=255
]
)
¶
c
–
int
m
–
int
y
–
int
k
–
int
a
–
int
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.
另请参阅
getCmyk()
setCmykF()
CMYK
Color
Model
PySide2.QtGui.QColor.
setCmykF
(
c
,
m
,
y
,
k
[
,
a=1.0
]
)
¶
c
–
qreal
m
–
qreal
y
–
qreal
k
–
qreal
a
–
qreal
这是重载函数。
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.
另请参阅
getCmykF()
setCmyk()
CMYK
Color
Model
PySide2.QtGui.QColor.
setGreen
(
green
)
¶
green
–
int
Sets the green color component of this color to
green
. Integer components are specified in the range 0-255.
PySide2.QtGui.QColor.
setGreenF
(
green
)
¶
green
–
qreal
Sets the green color component of this color to
green
。若
green
lies outside the 0.0-1.0 range, the color model will be changed to
ExtendedRgb
.
PySide2.QtGui.QColor.
setHsl
(
h
,
s
,
l
[
,
a=255
]
)
¶
h
–
int
s
–
int
l
–
int
a
–
int
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.
PySide2.QtGui.QColor.
setHslF
(
h
,
s
,
l
[
,
a=1.0
]
)
¶
h
–
qreal
s
–
qreal
l
–
qreal
a
–
qreal
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.
PySide2.QtGui.QColor.
setHsv
(
h
,
s
,
v
[
,
a=255
]
)
¶
h
–
int
s
–
int
v
–
int
a
–
int
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.
PySide2.QtGui.QColor.
setHsvF
(
h
,
s
,
v
[
,
a=1.0
]
)
¶
h
–
qreal
s
–
qreal
v
–
qreal
a
–
qreal
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.
PySide2.QtGui.QColor.
setNamedColor
(
name
)
¶
name – unicode
PySide2.QtGui.QColor.
setRed
(
red
)
¶
red
–
int
Sets the red color component of this color to
red
. Integer components are specified in the range 0-255.
PySide2.QtGui.QColor.
setRedF
(
red
)
¶
red
–
qreal
Sets the red color component of this color to
red
。若
red
lies outside the 0.0-1.0 range, the color model will be changed to
ExtendedRgb
.
PySide2.QtGui.QColor.
setRgb
(
rgb
)
¶
rgb – long
这是重载函数。
Sets the RGB value to
rgb
. The alpha value is set to opaque.
PySide2.QtGui.QColor.
setRgb
(
r
,
g
,
b
[
,
a=255
]
)
¶
r
–
int
g
–
int
b
–
int
a
–
int
Sets the RGB value to
r
,
g
,
b
and the alpha value to
a
.
All the values must be in the range 0-255.
PySide2.QtGui.QColor.
setRgbF
(
r
,
g
,
b
[
,
a=1.0
]
)
¶
r
–
qreal
g
–
qreal
b
–
qreal
a
–
qreal
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
.
PySide2.QtGui.QColor.
setRgba
(
rgba
)
¶
rgba – long
Sets the RGB value to
rgba
, including its alpha.
PySide2.QtGui.QColor.
spec
(
)
¶
返回如何指定颜色。
另请参阅
Spec
convertTo()
PySide2.QtGui.QColor.
toCmyk
(
)
¶
Creates and returns a CMYK
QColor
based on this color.
另请参阅
fromCmyk()
convertTo()
isValid()
CMYK
Color
Model
PySide2.QtGui.QColor.
toExtendedRgb
(
)
¶
Create and returns an extended RGB
QColor
based on this color.
另请参阅
PySide2.QtGui.QColor.
toHsl
(
)
¶
Creates and returns an HSL
QColor
based on this color.
另请参阅
fromHsl()
convertTo()
isValid()
HSL
Color
Model
PySide2.QtGui.QColor.
toHsv
(
)
¶
Creates and returns an HSV
QColor
based on this color.
另请参阅
fromHsv()
convertTo()
isValid()
HSV
Color
Model
PySide2.QtGui.QColor.
toTuple
(
)
¶
PyObject
PySide2.QtGui.QColor.
value
(
)
¶
int
Returns the value color component of this color.
PySide2.QtGui.QColor.
valueF
(
)
¶
qreal
Returns the value color component of this color.
PySide2.QtGui.QColor.
yellow
(
)
¶
int
Returns the yellow color component of this color.
PySide2.QtGui.QColor.
yellowF
(
)
¶
qreal
Returns the yellow color component of this color.
另请参阅
yellow()
getCmykF()
CMYK
Color
Model