![]() |
Qt 6.x
The Qt SDK
|
The QColor class provides colors based on RGB, HSV or CMYK values. More...
#include <qcolor.h>
Public Types | |
enum | Spec { Invalid , Rgb , Hsv , Cmyk , Hsl , ExtendedRgb } |
The type of color specified, either RGB, extended RGB, HSV, CMYK or HSL. More... | |
enum | NameFormat { HexRgb , HexArgb } |
How to format the output of the name() function. More... | |
Public Member Functions | |
constexpr | QColor () noexcept |
Constructs an invalid color with the RGB value (0, 0, 0). | |
QColor (Qt::GlobalColor color) noexcept | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Constructs a new color with a color value of color. | |
constexpr | QColor (int r, int g, int b, int a=255) noexcept |
Constructs a color with the RGB value r, g, b, and the alpha-channel (transparency) value of a. | |
QColor (QRgb rgb) noexcept | |
Constructs a color with the value color. | |
QColor (QRgba64 rgba64) noexcept | |
QColor (const QString &name) | |
Constructs a named color in the same way as setNamedColor() using the given name. | |
QColor (QStringView name) | |
QColor (const char *aname) | |
Constructs a named color in the same way as setNamedColor() using the given name. | |
QColor (QLatin1StringView name) | |
Constructs a named color in the same way as setNamedColor() using the given name. | |
QColor (Spec spec) noexcept | |
QColor & | operator= (Qt::GlobalColor color) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Assigns a copy of color and returns a reference to this color. | |
bool | isValid () const noexcept |
Returns true if the color is valid; otherwise returns false . | |
QString | name (NameFormat format=HexRgb) const |
Spec | spec () const noexcept |
Returns how the color was specified. | |
int | alpha () const noexcept |
Returns the alpha color component of this color. | |
void | setAlpha (int alpha) |
Sets the alpha of this color to alpha. | |
float | alphaF () const noexcept |
Returns the alpha color component of this color. | |
void | setAlphaF (float alpha) |
Sets the alpha of this color to alpha. | |
int | red () const noexcept |
Returns the red color component of this color. | |
int | green () const noexcept |
Returns the green color component of this color. | |
int | blue () const noexcept |
Returns the blue color component of this color. | |
void | setRed (int red) |
Sets the red color component of this color to red. | |
void | setGreen (int green) |
Sets the green color component of this color to green. | |
void | setBlue (int blue) |
Sets the blue color component of this color to blue. | |
float | redF () const noexcept |
Returns the red color component of this color. | |
float | greenF () const noexcept |
Returns the green color component of this color. | |
float | blueF () const noexcept |
Returns the blue color component of this color. | |
void | setRedF (float red) |
Sets the red color component of this color to red. | |
void | setGreenF (float green) |
Sets the green color component of this color to green. | |
void | setBlueF (float blue) |
Sets the blue color component of this color to blue. | |
void | getRgb (int *r, int *g, int *b, int *a=nullptr) const |
Sets the contents pointed to by r, g, b, and a, to the red, green, blue, and alpha-channel (transparency) components of the color's RGB value. | |
void | setRgb (int r, int g, int b, int a=255) |
Sets the RGB value to r, g, b and the alpha value to a. | |
void | getRgbF (float *r, float *g, float *b, float *a=nullptr) const |
Sets the contents pointed to by r, g, b, and a, to the red, green, blue, and alpha-channel (transparency) components of the color's RGB value. | |
void | setRgbF (float r, float g, float b, float a=1.0) |
Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency). | |
QRgba64 | rgba64 () const noexcept |
void | setRgba64 (QRgba64 rgba) noexcept |
QRgb | rgba () const noexcept |
Returns the RGB value of the color, including its alpha. | |
void | setRgba (QRgb rgba) noexcept |
Sets the RGB value to rgba, including its alpha. | |
QRgb | rgb () const noexcept |
Returns the RGB value of the color. | |
void | setRgb (QRgb rgb) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the RGB value to rgb. | |
int | hue () const noexcept |
Returns the HSV hue color component of this color. | |
int | saturation () const noexcept |
Returns the HSV saturation color component of this color. | |
int | hsvHue () const noexcept |
Returns the HSV hue color component of this color. | |
int | hsvSaturation () const noexcept |
Returns the HSV saturation color component of this color. | |
int | value () const noexcept |
Returns the value color component of this color. | |
float | hueF () const noexcept |
Returns the HSV hue color component of this color. | |
float | saturationF () const noexcept |
Returns the HSV saturation color component of this color. | |
float | hsvHueF () const noexcept |
Returns the hue color component of this color. | |
float | hsvSaturationF () const noexcept |
Returns the HSV saturation color component of this color. | |
float | valueF () const noexcept |
Returns the value color component of this color. | |
void | getHsv (int *h, int *s, int *v, int *a=nullptr) const |
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (transparency) components of the color's HSV value. | |
void | setHsv (int h, int s, int v, int a=255) |
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha component of the HSV color. | |
void | getHsvF (float *h, float *s, float *v, float *a=nullptr) const |
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (transparency) components of the color's HSV value. | |
void | setHsvF (float h, float s, float v, float a=1.0) |
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha component of the HSV color. | |
int | cyan () const noexcept |
Returns the cyan color component of this color. | |
int | magenta () const noexcept |
Returns the magenta color component of this color. | |
int | yellow () const noexcept |
Returns the yellow color component of this color. | |
int | black () const noexcept |
Returns the black color component of this color. | |
float | cyanF () const noexcept |
Returns the cyan color component of this color. | |
float | magentaF () const noexcept |
Returns the magenta color component of this color. | |
float | yellowF () const noexcept |
Returns the yellow color component of this color. | |
float | blackF () const noexcept |
Returns the black color component of this color. | |
void | getCmyk (int *c, int *m, int *y, int *k, int *a=nullptr) const |
Sets the contents pointed to by c, m, y, k, and a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components of the color's CMYK value. | |
void | setCmyk (int c, int m, int y, int k, int a=255) |
Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e. | |
void | getCmykF (float *c, float *m, float *y, float *k, float *a=nullptr) const |
Sets the contents pointed to by c, m, y, k, and a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components of the color's CMYK value. | |
void | setCmykF (float c, float m, float y, float k, float a=1.0) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e. | |
int | hslHue () const noexcept |
int | hslSaturation () const noexcept |
int | lightness () const noexcept |
float | hslHueF () const noexcept |
float | hslSaturationF () const noexcept |
float | lightnessF () const noexcept |
void | getHsl (int *h, int *s, int *l, int *a=nullptr) const |
void | setHsl (int h, int s, int l, int a=255) |
void | getHslF (float *h, float *s, float *l, float *a=nullptr) const |
void | setHslF (float h, float s, float l, float a=1.0) |
QColor | toRgb () const noexcept |
Create and returns an RGB QColor based on this color. | |
QColor | toHsv () const noexcept |
Creates and returns an HSV QColor based on this color. | |
QColor | toCmyk () const noexcept |
Creates and returns a CMYK QColor based on this color. | |
QColor | toHsl () const noexcept |
Creates and returns an HSL QColor based on this color. | |
QColor | toExtendedRgb () const noexcept |
Create and returns an extended RGB QColor based on this color. | |
QColor | convertTo (Spec colorSpec) const noexcept |
Creates a copy of this color in the format specified by colorSpec. | |
QColor | lighter (int f=150) const noexcept |
QColor | darker (int f=200) const noexcept |
bool | operator== (const QColor &c) const noexcept |
Returns true if this color has the same color specification and component values as color; otherwise returns false . | |
bool | operator!= (const QColor &c) const noexcept |
Returns true if this color has different color specification or component values from color; otherwise returns false . | |
operator QVariant () const | |
Returns the color as a QVariant. | |
Static Public Member Functions | |
static QColor | fromString (QAnyStringView name) noexcept |
static QStringList | colorNames () |
Returns a QStringList containing the color names Qt knows about. | |
static QColor | fromRgb (QRgb rgb) noexcept |
Static convenience function that returns a QColor constructed from the given QRgb value rgb. | |
static QColor | fromRgba (QRgb rgba) noexcept |
Static convenience function that returns a QColor constructed from the given QRgb value rgba. | |
static QColor | fromRgb (int r, int g, int b, int a=255) |
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 (float r, float g, float b, float a=1.0) |
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 | fromRgba64 (ushort r, ushort g, ushort b, ushort a=USHRT_MAX) noexcept |
static QColor | fromRgba64 (QRgba64 rgba) noexcept |
static QColor | fromHsv (int h, int s, int v, int a=255) |
Static 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 (float h, float s, float v, float a=1.0) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.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 | fromCmyk (int c, int m, int y, int k, int a=255) |
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 (float c, float m, float y, float k, float a=1.0) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.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 | fromHsl (int h, int s, int l, int a=255) |
static QColor | fromHslF (float h, float s, float l, float a=1.0) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
static bool | isValidColorName (QAnyStringView) noexcept |
Friends | |
class | QColormap |
Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &, const QColor &) |
Writes the color to the stream. | |
Q_GUI_EXPORT QDataStream & | operator>> (QDataStream &, QColor &) |
Reads the color from the stream. | |
Related Symbols | |
(Note that these are not member symbols.) | |
QDataStream & | operator<< (QDataStream &stream, const QColor &color) |
Writes the color to the stream. | |
QDataStream & | operator>> (QDataStream &stream, QColor &color) |
Reads the color from the stream. | |
int | qRed (QRgb rgb) |
Returns the red component of the ARGB quadruplet rgb. | |
int | qGreen (QRgb rgb) |
Returns the green component of the ARGB quadruplet rgb. | |
int | qBlue (QRgb rgb) |
Returns the blue component of the ARGB quadruplet rgb. | |
int | qAlpha (QRgb rgba) |
Returns the alpha component of the ARGB quadruplet rgba. | |
QRgb | qRgb (int r, int g, int b) |
Returns the ARGB quadruplet (255, {r}, {g}, {b}). | |
QRgb | qRgba (int r, int g, int b, int a) |
Returns the ARGB quadruplet ({a}, {r}, {g}, {b}). | |
int | qGray (int r, int g, int b) |
Returns a gray value (0 to 255) from the (r, g, b) triplet. | |
int | qGray (QRgb rgb) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QRgb | qPremultiply (QRgb rgb) |
QRgb | qUnpremultiply (QRgb rgb) |
QRgb | |
An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int. | |
The QColor class provides colors based on RGB, HSV or CMYK values.
\inmodule QtGui
A color is normally specified in terms of RGB (red, green, and blue) components, but it is also possible to specify it in terms of HSV (hue, saturation, and value) and CMYK (cyan, magenta, yellow and black) components. In addition a color can be specified using a color name. The color name can be any of the SVG 1.0 color names.
\table \header
The QColor constructor creates the color based on RGB values. To create a QColor based on either HSV or CMYK values, use the toHsv() and toCmyk() functions respectively. These functions return a copy of the color using the desired format. In addition the static fromRgb(), fromHsv() and fromCmyk() functions create colors from the specified values. Alternatively, a color can be converted to any of the three formats using the convertTo() function (returning a copy of the color in the desired format), or any of the setRgb(), setHsv() and setCmyk() functions altering this color's format. The spec() function tells how the color was specified.
A color can be set by passing an RGB string (such as "#112233"), or an ARGB string (such as "#ff112233") or a color name (such as "blue"), to the fromString() function. The color names are taken from the SVG 1.0 color names. The name() function returns the name of the color in the format "#RRGGBB". Colors can also be set using setRgb(), setHsv() and setCmyk(). To get a lighter or darker color use the lighter() and darker() functions respectively.
The isValid() function indicates whether a QColor is legal at all. For example, a RGB color with RGB values out of range is illegal. For performance reasons, QColor mostly disregards illegal colors, and for that reason, the result of using an invalid color is undefined.
The color components can be retrieved individually, e.g with red(), hue() and cyan(). The values of the color components can also be retrieved in one go using the getRgb(), getHsv() and getCmyk() functions. Using the RGB color model, the color components can in addition be accessed with rgb().
There are several related non-members: QRgb is a typdef for an unsigned int representing the RGB value triplet (r, g, b). Note that it also can hold a value for the alpha-channel (for more information, see the \l {QColor::Alpha-Blended Drawing}{Alpha-Blended Drawing} section). The qRed(), qBlue() and qGreen() functions return the respective component of the given QRgb value, while the qRgb() and qRgba() functions create and return the QRgb triplet based on the given component values. Finally, the qAlpha() function returns the alpha component of the provided QRgb, and the qGray() function calculates and return a gray value based on the given value.
QColor is platform and device independent. The QColormap class maps the color to the hardware.
For more information about painting in general, see the \l{Paint System} documentation.
enum QColor::NameFormat |
How to format the output of the name() function.
\value HexRgb #RRGGBB A "#" character followed by three two-digit hexadecimal numbers (i.e. {#RRGGBB}). \value HexArgb #AARRGGBB A "#" character followed by four two-digit hexadecimal numbers (i.e.
{#AARRGGBB}).
Enumerator | |
---|---|
HexRgb | |
HexArgb |
enum QColor::Spec |
The type of color specified, either RGB, extended RGB, HSV, CMYK or HSL.
\value Rgb \value Hsv \value Cmyk \value Hsl \value ExtendedRgb \value Invalid
Enumerator | |
---|---|
Invalid | |
Rgb | |
Hsv | |
Cmyk | |
Hsl | |
ExtendedRgb |
|
inlineconstexprnoexcept |
Constructs an invalid color with the RGB value (0, 0, 0).
An invalid color is a color that is not properly set up for the underlying window system.
The alpha value of an invalid color is unspecified.
Definition at line 38 of file qcolor.h.
Referenced by fromCmyk(), fromCmykF(), fromHsl(), fromHslF(), fromHsv(), fromHsvF(), fromRgb(), and fromRgbF().
|
noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Constructs a new color with a color value of color.
Definition at line 655 of file qcolor.cpp.
References qAlpha(), qBlue(), qGreen(), qRed(), QRGB, QRgb, and QRGBA.
|
inlineconstexprnoexcept |
|
noexcept |
|
noexcept |
Constructs a color with the value rgba64.
Definition at line 748 of file qcolor.cpp.
|
inline |
|
inlineexplicit |
|
inline |
Constructs a named color in the same way as setNamedColor() using the given name.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Constructs a named color in the same way as setNamedColor() using the given name.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
noexcept |
Constructs a color with the given spec.
This function is primarily present to avoid that QColor::Invalid becomes a valid color by accident.
Definition at line 762 of file qcolor.cpp.
|
noexcept |
Returns the alpha color component of this color.
Definition at line 1466 of file qcolor.cpp.
References castF16(), ExtendedRgb, qRound(), and qt_div_257().
Referenced by QPdfEnginePrivate::addBrushPattern(), QQuickTextNodeEngine::addToSceneGraph(), cgColorForQColor(), QQuick3DParticleEmitter::emitParticle(), QX11PlatformPixmap::fill(), QuickTestResult::fuzzyCompare(), QQuickShapeCurveNode::hasStroke(), QSGSoftwareInternalRectangleNode::isOpaque(), QStaticTextPrivate::paintText(), QQuickColorImage::pixmapChange(), qt_accentColor(), QWizardPrivate::recreateLayout(), setBlue(), QQuickPen::setColor(), QSGFlatColorMaterial::setColor(), setGreen(), QQuickPen::setPixelAligned(), setRed(), QQuickPen::setWidth(), QQuickColorProvider::tint(), QBlitterPaintEnginePrivate::updateBrushState(), QPainterPrivate::updateEmulationSpecifier(), QSGBasicInternalRectangleNode::updateGeometry(), QSGDefaultInternalRectangleNode::updateMaterialBlending(), QX11PaintEngine::updatePen(), QDeclarativeCircleMapItemPrivateCPU::updatePolish(), QDeclarativePolygonMapItemPrivateCPU::updatePolish(), QDeclarativeRectangleMapItemPrivateCPU::updatePolish(), and QPdfEngine::updateState().
|
noexcept |
Returns the alpha color component of this color.
Definition at line 1497 of file qcolor.cpp.
References castF16(), and ExtendedRgb.
Referenced by QOpenGLWidgetPaintDevicePrivate::beginPaint(), QRhiD3D11::beginPass(), QRhiGles2::beginPass(), QRhiVulkan::beginPass(), QRhiMetalData::createDefaultRenderPass(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QQuick3DParticle::opacity(), qt_premultiplyColor(), setBlueF(), setGreenF(), setRedF(), QSpanData::setup(), QQuick3DSceneRenderer::synchronize(), QQuickColorProvider::tint(), QQuickMultiEffectPrivate::updateColorizationColor(), QQuickMultiEffectPrivate::updateShadowColor(), and QT_BEGIN_NAMESPACE::QQuickShapeCurveMaterialShader::updateUniformData().
|
noexcept |
Returns the black color component of this color.
Definition at line 1951 of file qcolor.cpp.
References black(), Cmyk, Invalid, qt_div_257(), and toCmyk().
Referenced by black().
|
noexcept |
Returns the black color component of this color.
Definition at line 1999 of file qcolor.cpp.
References blackF(), Cmyk, Invalid, and toCmyk().
Referenced by blackF().
|
noexcept |
Returns the blue color component of this color.
Definition at line 1583 of file qcolor.cpp.
References blue(), Invalid, qt_div_257(), Rgb, and toRgb().
Referenced by QQuickColorDialogImpl::blue(), QQuickColorInputs::blue(), blue(), cgColorForQColor(), QQC2_NAMESPACE::QMacStyle::drawComplexControl(), QMacStyle::drawComplexControl(), QQC2::QWindowsXPStyle::drawControl(), QWindowsVistaStyle::drawControl(), QQC2::QWindowsStyle::drawPrimitive(), QQuick3DParticleEmitter::emitParticle(), QuickTestResult::fuzzyCompare(), QCommonStyle::generatedIconPixmap(), QQC2::QCommonStyle::generatedIconPixmap(), QCommandLinkButtonPrivate::mergedColors(), QQuickFusionStyle::mergedColors(), mixColors(), QStaticTextPrivate::paintText(), qt_accentColor(), qt_graphicsItem_highlightSelected(), QCoreGraphicsPaintEnginePrivate::setFillBrush(), setGreen(), and setRed().
|
noexcept |
Returns the blue color component of this color.
Definition at line 1675 of file qcolor.cpp.
References blueF(), castF16(), ExtendedRgb, Invalid, Rgb, and toRgb().
Referenced by QRhiD3D11::beginPass(), QRhiGles2::beginPass(), QRhiVulkan::beginPass(), blueF(), QRhiMetalData::createDefaultRenderPass(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QColorTransform::map(), QPdfEngine::setBrush(), setGreenF(), QPdfEngine::setPen(), setRedF(), QQuick3DSceneRenderer::synchronize(), QQuickColorProvider::tint(), QQuickMultiEffectPrivate::updateColorizationColor(), QQuick3DRenderLayerHelpers::updateLayerNodeHelper(), QQuickMultiEffectPrivate::updateShadowColor(), and QT_BEGIN_NAMESPACE::QQuickShapeCurveMaterialShader::updateUniformData().
|
static |
Returns a QStringList containing the color names Qt knows about.
Definition at line 1002 of file qcolor.cpp.
References get_colornames().
|
noexcept |
Creates a copy of this color in the format specified by colorSpec.
Definition at line 2336 of file qcolor.cpp.
Referenced by darker(), darkerShade(), lighter(), and lighterShade().
|
noexcept |
Returns the cyan color component of this color.
Definition at line 1914 of file qcolor.cpp.
References Cmyk, cyan(), Invalid, qt_div_257(), and toCmyk().
Referenced by cyan().
|
noexcept |
Returns the cyan color component of this color.
Definition at line 1963 of file qcolor.cpp.
References Cmyk, cyanF(), Invalid, and toCmyk().
Referenced by cyanF().
|
noexcept |
Returns a darker (or lighter) color, but does not change this object.
If the factor is greater than 100, this functions returns a darker color. Setting factor to 300 returns a color that has one-third the brightness. If the factor is less than 100, the return color is lighter, but we recommend using the lighter() function for this purpose. If the factor is 0 or negative, the return value is unspecified.
The function converts the current color to HSV, divides the value (V) component by factor and converts the color back to it's original color spec.
Definition at line 2857 of file qcolor.cpp.
References convertTo().
Referenced by QQuickFusionStyle::buttonColor(), QQC2_NAMESPACE::QMacStyle::drawControl(), QMacStyle::drawControl(), QQC2::QWindowsXPStyle::drawControl(), QWindowsVistaStyle::drawControl(), QQC2::QStyleHelper::drawDial(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QQuickFusionStyle::highlightedOutline(), QQuickFusionDial::paint(), QWindowsVistaStyle::polish(), populateDarkSystemBasePalette(), populateLightSystemBasePalette(), qt_fusionPalette(), qt_mac_createSystemPalette(), standardPalette(), QGtk3Storage::standardPalette(), QStyle::standardPalette(), QQC2::QStyle::standardPalette(), toolTipPalette(), and QAndroidPlatformTheme::updateStyle().
|
static |
Static convenience function that returns a QColor constructed from the given CMYK color values: c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e.
transparency).
All the values must be in the range 0-255.
Definition at line 2741 of file qcolor.cpp.
References QColor(), Cmyk, and qWarning.
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Static convenience function that returns a QColor constructed from the given CMYK color values: c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e.
transparency).
All the values must be in the range 0.0-1.0.
Definition at line 2773 of file qcolor.cpp.
References QColor(), Cmyk, qRound(), and qWarning.
|
static |
Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), l (lightness), and a (alpha-channel, i.e. transparency).
The value of s, l, and a must all be in the range 0-255; the value of h must be in the range 0-359.
Definition at line 2562 of file qcolor.cpp.
References QColor(), Hsl, and qWarning.
Referenced by parseColorValue(), and qt_color_from_string().
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), l (lightness), and a (alpha-channel, i.e. transparency).
All the values must be in the range 0.0-1.0.
Definition at line 2594 of file qcolor.cpp.
References QColor(), Hsl, qRound(), and qWarning.
Referenced by QQuickAbstractColorPicker::color(), QQuickColorDialogImpl::color(), QQuickSaturationLightnessPicker::colorAt(), QQuickColorProvider::fromHslF(), and genRandom().
|
static |
Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), v (value), and a (alpha-channel, i.e.
transparency).
The value of s, v, and a must all be in the range 0-255; the value of h must be in the range 0-359.
Definition at line 2499 of file qcolor.cpp.
References QColor(), Hsv, and qWarning.
Referenced by QGraphicsScenePrivate::draw(), QtPrivate::QColorLuminancePicker::paintEvent(), and parseColorValue().
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), v (value), and a (alpha-channel, i.e.
transparency).
All the values must be in the range 0.0-1.0.
Definition at line 2530 of file qcolor.cpp.
References QColor(), Hsv, qRound(), and qWarning.
Referenced by QQuickAbstractColorPicker::color(), QQuickColorDialogImpl::color(), QQuickColorInputs::color(), QQuickColorProvider::fromHsvF(), and genRandom().
|
static |
Static convenience function that returns a QColor constructed from the RGB color values, r (red), g (green), b (blue), and a (alpha-channel, i.e.
transparency).
All the values must be in the range 0-255.
Definition at line 2399 of file qcolor.cpp.
References QColor(), qWarning, and Rgb.
Static convenience function that returns a QColor constructed from the given QRgb value rgb.
The alpha component of rgb is ignored (i.e. it is automatically set to 255), use the fromRgba() function to include the alpha-channel specified by the given QRgb value.
Definition at line 2369 of file qcolor.cpp.
References qBlue(), qGreen(), qRed(), and rgb.
Referenced by QQuickImagineTheme::initialize(), parseColorValue(), QWindowsVistaStyle::polish(), qt_accentColor(), QQuickMaterialStyle::switchCheckedHandleColor(), and QQuickMaterialStyle::switchDisabledCheckedHandleColor().
Static convenience function that returns a QColor constructed from the given QRgb value rgba.
Unlike the fromRgb() function, the alpha-channel specified by the given QRgb value is included.
Definition at line 2385 of file qcolor.cpp.
References qAlpha(), qBlue(), qGreen(), and qRed().
Referenced by QQuickUniversalStyle::accent(), QQuickUniversalStyle::background(), QQuickBasicStyle::backgroundColor(), QQuickMaterialStyle::backgroundDimColor(), QQuickBasicStyle::buttonCheckedColor(), QQuickBasicStyle::buttonCheckedFocusColor(), QQuickBasicStyle::buttonCheckedPressedColor(), QQuickBasicStyle::buttonColor(), QQuickMaterialStyle::buttonColor(), QQuickBasicStyle::buttonPressedColor(), QQuickText::color(), QQuickBasicStyle::delegateColor(), QQuickBasicStyle::delegateFocusColor(), QQuickBasicStyle::delegatePressedColor(), QQuickMaterialStyle::dialogColor(), QQuickBasicStyle::disabledDarkColor(), QQuickBasicStyle::disabledLightColor(), QQuickMaterialStyle::dividerColor(), QQuickMaterialStyle::dropShadowColor(), QQuickBasicStyle::focusColor(), QQuickBasicStyle::focusLightColor(), QQuickBasicStyle::focusPressedColor(), QQuickMaterialStyle::foreground(), QQuickUniversalStyle::foreground(), QQuickMaterialStyle::frameColor(), QQuickBasicStyle::frameDarkColor(), QQuickBasicStyle::frameLightColor(), fromString(), QQuickMaterialStyle::hintTextColor(), QQuickMaterialStyle::iconColor(), QQuickMaterialStyle::iconDisabledColor(), QQuickBasicStyle::indicatorDisabledColor(), QQuickBasicStyle::indicatorFrameColor(), QQuickBasicStyle::indicatorFrameDisabledColor(), QQuickBasicStyle::indicatorFramePressedColor(), QQuickBasicStyle::indicatorPressedColor(), QQuickBasicTheme::initialize(), QQuickText::linkColor(), QQuickMaterialStyle::listHighlightColor(), QQuickBasicStyle::overlayDimColor(), QQuickBasicStyle::overlayModalColor(), QQuickBasicStyle::pageIndicatorColor(), QTableView::paintEvent(), QuickTestImageObject::pixel(), QQuickMaterialStyle::primaryColor(), QQuickMaterialStyle::primaryHighlightedTextColor(), QQuickMaterialStyle::primaryTextColor(), QQuickBasicStyle::progressBarColor(), qt_accentColor(), qt_color_from_string(), QQuickMaterialStyle::rippleColor(), QSvgPaintEngine::saveGradientStops(), QQuickBasicStyle::scrollBarColor(), QQuickMaterialStyle::scrollBarColor(), QQuickMaterialStyle::scrollBarHoveredColor(), QQuickBasicStyle::scrollBarPressedColor(), QQuickMaterialStyle::scrollBarPressedColor(), QQuickMaterialStyle::secondaryTextColor(), QQuickBasicStyle::separatorColor(), QQuickMaterialStyle::sliderDisabledColor(), QQuickMaterialStyle::spinBoxDisabledIconColor(), QQuickColorProvider::stringFromRgba(), QQuickText::styleColor(), QQuickMaterialStyle::switchDisabledCheckedIconColor(), QQuickMaterialStyle::switchDisabledCheckedTrackColor(), QQuickMaterialStyle::switchDisabledUncheckedHandleColor(), QQuickMaterialStyle::switchDisabledUncheckedIconColor(), QQuickMaterialStyle::switchDisabledUncheckedTrackBorderColor(), QQuickMaterialStyle::switchDisabledUncheckedTrackColor(), QQuickMaterialStyle::switchUncheckedTrackColor(), QQuickUniversalStyle::systemColor(), QQuickBasicStyle::tabButtonCheckedPressedColor(), QQuickBasicStyle::tabButtonColor(), QQuickBasicStyle::tabButtonPressedColor(), QQuickBasicStyle::textColor(), QQuickBasicStyle::textDarkColor(), QQuickBasicStyle::textDisabledColor(), QQuickBasicStyle::textDisabledLightColor(), QQuickMaterialStyle::textFieldFilledContainerColor(), QQuickBasicStyle::textLightColor(), QQuickBasicStyle::textLinkColor(), QQuickBasicStyle::textPlaceholderColor(), QQuickBasicStyle::textSelectionColor(), QQuickBasicStyle::toolButtonColor(), QQuickMaterialStyle::toolTextColor(), QQuickBasicBusyIndicatorNode::updateCurrentTime(), and QQuickText::updatePaintNode().
Static convenience function that returns a QColor constructed from the given QRgba64 value rgba64.
Definition at line 2482 of file qcolor.cpp.
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).
Definition at line 2467 of file qcolor.cpp.
References qRgba64().
Referenced by fromString().
|
static |
Static convenience function that returns a QColor constructed from the RGB color values, r (red), g (green), b (blue), and a (alpha-channel, i.e.
transparency).
The alpha value must be in the range 0.0-1.0. If any of the other values are outside the range of 0.0-1.0 the color model will be set as ExtendedRgb
.
Definition at line 2427 of file qcolor.cpp.
References QColor(), castF16(), ExtendedRgb, qRound(), qWarning, and Rgb.
Referenced by aiColorToQColor(), aiColorToQColor(), QGtk3ColorDialogHelper::currentColor(), QSGRhiAtlasTexture::Atlas::enqueueTextureUpload(), QQuickColorProvider::fromRgbF(), genRandom(), QQuick3DInstancing::InstanceTableEntry::getColor(), qPremultiplyWithExtraAlpha(), qsg_premultiply_color(), qt_premultiply_color(), query_colormap(), ScreenMapPass::renderPrep(), setLightProperties(), color::sRGBToLinearColor(), QQuick3DSceneRenderer::synchronize(), QQuickColorProvider::tint(), QSG24BitTextMaskRhiShader::updateGraphicsPipelineState(), QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::updateGraphicsPipelineState(), and gradientcreationsnippet::wrapper().
|
staticnoexcept |
Returns an RGB QColor parsed from name, which may be in one of these formats:
\list
transparent
- representing the absence of a color. \endlistReturns an invalid color if name cannot be parsed.
Definition at line 980 of file qcolor.cpp.
References fromRgba(), fromRgba64(), get_hex_rgb(), and get_named_rgb().
Referenced by QTextHtmlParser::applyAttributes(), QQuickColorProvider::colorFromString(), QQuickColorValueType::create(), QQuickMaterialStyle::initGlobals(), QQuickUniversalStyle::initGlobals(), QQuick3DFileInstancing::loadFromXmlFile(), QQuickStyledTextPrivate::parseFontAttributes(), QCss::Parser::parseHexColor(), qt_color_from_string(), QDeclarativeGeoMapCopyrightNotice::rasterizeHtmlAndUpdate(), resolveColor(), QQuickColorProvider::rgbaFromString(), QtWaylandClient::QWaylandTextInputMethod::text_input_method_v1_input_method_event_attribute(), and toColor().
Sets the contents pointed to by c, m, y, k, and a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components of the color's CMYK value.
These components can be retrieved individually using the cyan(), magenta(), yellow(), black() and alpha() functions.
Definition at line 2626 of file qcolor.cpp.
References Cmyk, getCmyk(), Invalid, qt_div_257(), and toCmyk().
Referenced by getCmyk().
Sets the contents pointed to by c, m, y, k, and a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components of the color's CMYK value.
These components can be retrieved individually using the cyanF(), magentaF(), yellowF(), blackF() and alphaF() functions.
Definition at line 2655 of file qcolor.cpp.
References Cmyk, getCmykF(), Invalid, and toCmyk().
Referenced by getCmykF().
Sets the contents pointed to by h, s, l, and a, to the hue, saturation, lightness, and alpha-channel (transparency) components of the color's HSL value.
These components can be retrieved individually using the hslHue(), hslSaturation(), lightness() and alpha() functions.
Definition at line 1157 of file qcolor.cpp.
References getHsl(), Hsl, Invalid, qt_div_257(), and toHsl().
Referenced by getHsl().
Sets the contents pointed to by h, s, l, and a, to the hue, saturation, lightness, and alpha-channel (transparency) components of the color's HSL value.
These components can be retrieved individually using the hslHueF(), hslSaturationF(), lightnessF() and alphaF() functions.
Definition at line 1127 of file qcolor.cpp.
References getHslF(), Hsl, Invalid, and toHsl().
Referenced by genRandom(), and getHslF().
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (transparency) components of the color's HSV value.
These components can be retrieved individually using the hue(), saturation(), value() and alpha() functions.
Definition at line 1045 of file qcolor.cpp.
References getHsv(), Hsv, Invalid, qt_div_257(), and toHsv().
Referenced by darkenPixmap(), QQC2_NAMESPACE::darkenPixmap(), QAndroidStyle::AndroidControl::drawControl(), QQC2::QCommonStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), and getHsv().
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (transparency) components of the color's HSV value.
These components can be retrieved individually using the hueF(), saturationF(), valueF() and alphaF() functions.
Definition at line 1017 of file qcolor.cpp.
References getHsvF(), Hsv, Invalid, and toHsv().
Referenced by genRandom(), and getHsvF().
Sets the contents pointed to by r, g, b, and a, to the red, green, blue, and alpha-channel (transparency) components of the color's RGB value.
These components can be retrieved individually using the red(), green(), blue() and alpha() functions.
Definition at line 1287 of file qcolor.cpp.
References getRgb(), Invalid, qt_div_257(), Rgb, and toRgb().
Referenced by getRgb().
Sets the contents pointed to by r, g, b, and a, to the red, green, blue, and alpha-channel (transparency) components of the color's RGB value.
These components can be retrieved individually using the redF(), greenF(), blueF() and alphaF() functions.
Definition at line 1252 of file qcolor.cpp.
References castF16(), ExtendedRgb, getRgbF(), Invalid, Rgb, and toRgb().
Referenced by genRandom(), and getRgbF().
|
noexcept |
Returns the green color component of this color.
Definition at line 1555 of file qcolor.cpp.
References green(), Invalid, qt_div_257(), Rgb, and toRgb().
Referenced by cgColorForQColor(), QQC2_NAMESPACE::QMacStyle::drawComplexControl(), QMacStyle::drawComplexControl(), QQC2::QWindowsXPStyle::drawControl(), QWindowsVistaStyle::drawControl(), QQC2::QWindowsStyle::drawPrimitive(), QQuick3DParticleEmitter::emitParticle(), QuickTestResult::fuzzyCompare(), QCommonStyle::generatedIconPixmap(), QQC2::QCommonStyle::generatedIconPixmap(), QQuickColorDialogImpl::green(), QQuickColorInputs::green(), green(), QCommandLinkButtonPrivate::mergedColors(), QQuickFusionStyle::mergedColors(), mixColors(), QStaticTextPrivate::paintText(), qt_accentColor(), qt_graphicsItem_highlightSelected(), setBlue(), QCoreGraphicsPaintEnginePrivate::setFillBrush(), and setRed().
|
noexcept |
Returns the green color component of this color.
Definition at line 1643 of file qcolor.cpp.
References castF16(), ExtendedRgb, greenF(), Invalid, Rgb, and toRgb().
Referenced by QRhiD3D11::beginPass(), QRhiGles2::beginPass(), QRhiVulkan::beginPass(), QRhiMetalData::createDefaultRenderPass(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QMacStyle::drawPrimitive(), greenF(), QColorTransform::map(), setBlueF(), QPdfEngine::setBrush(), QPdfEngine::setPen(), setRedF(), QQuick3DSceneRenderer::synchronize(), QQuickColorProvider::tint(), QQuickMultiEffectPrivate::updateColorizationColor(), QQuick3DRenderLayerHelpers::updateLayerNodeHelper(), QQuickMultiEffectPrivate::updateShadowColor(), and QT_BEGIN_NAMESPACE::QQuickShapeCurveMaterialShader::updateUniformData().
|
noexcept |
|
noexcept |
|
noexcept |
Returns the HSL saturation color component of this color.
Definition at line 1846 of file qcolor.cpp.
References Hsl, hslSaturation(), Invalid, qt_div_257(), and toHsl().
Referenced by hslSaturation().
|
noexcept |
Returns the HSL saturation color component of this color.
Definition at line 1888 of file qcolor.cpp.
References Hsl, hslSaturationF(), Invalid, and toHsl().
Referenced by hslSaturationF().
|
noexcept |
|
noexcept |
|
noexcept |
Returns the HSV saturation color component of this color.
Definition at line 1744 of file qcolor.cpp.
References Hsv, Invalid, qt_div_257(), saturation(), and toHsv().
Referenced by saturation().
|
noexcept |
Returns the HSV saturation color component of this color.
Definition at line 1806 of file qcolor.cpp.
References Hsv, Invalid, saturationF(), and toHsv().
Referenced by saturationF().
|
noexcept |
Returns the HSV hue color component of this color.
The color is implicitly converted to HSV.
Definition at line 1708 of file qcolor.cpp.
References hsvHue().
Referenced by QQuickFusionStyle::buttonColor(), QQC2::QStyleHelper::drawDial(), QQuickFusionStyle::highlightedOutline(), hsvHue(), toHsl(), and toHsv().
|
noexcept |
Returns the HSV hue color component of this color.
The color is implicitly converted to HSV.
Definition at line 1770 of file qcolor.cpp.
References hsvHueF().
Referenced by darkerShade(), hsvHueF(), and lighterShade().
|
inlinenoexcept |
Returns true
if the color is valid; otherwise returns false
.
Definition at line 285 of file qcolor.h.
References Invalid.
Referenced by QQuickTextNodeEngine::addGlyphsInRange(), QQC2::QCommonStyle::drawComplexControl(), QCommonStyle::drawComplexControl(), QAndroidStyle::drawComplexControl(), QAndroidStyle::AndroidControl::drawControl(), QQC2::QCommonStyle::drawPrimitive(), QQC2::QWindowsStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), drawTextItemDecoration(), QTabBarPrivate::initBasicStyleOption(), QQuickTextNodeEngine::BinaryTreeNode::insert(), QSGDefaultPainterNode::paint(), QCss::Parser::parseHexColor(), qt_accentColor(), QWindowsIntegration::setApplicationBadge(), ScreenWidget::setColor(), QIOSColorDialog::show(), toCmyk(), toExtendedRgb(), toHsl(), toHsv(), and toRgb().
|
staticnoexcept |
Returns true
if the name is a valid color name and can be used to construct a valid QColor object, otherwise returns false.
It uses the same algorithm used in fromString().
Definition at line 950 of file qcolor.cpp.
References fromString().
|
noexcept |
Returns a lighter (or darker) color, but does not change this object.
If the factor is greater than 100, this functions returns a lighter color. Setting factor to 150 returns a color that is 50% brighter. If the factor is less than 100, the return color is darker, but we recommend using the darker() function for this purpose. If the factor is 0 or negative, the return value is unspecified.
The function converts the current color to HSV, multiplies the value (V) component by factor and converts the color back to it's original color spec.
Definition at line 2812 of file qcolor.cpp.
References convertTo().
Referenced by QQuickFusionStyle::buttonColor(), QQuickFusionStyle::buttonOutline(), QQC2_NAMESPACE::QMacStyle::drawControl(), QMacStyle::drawControl(), QQC2::QStyleHelper::drawDial(), QQuickFusionStyle::gradientStart(), QQuickFusionStyle::gradientStop(), QQuickFusionDial::paint(), populateDarkSystemBasePalette(), qt_ensure_default_accent_color(), qt_fusionPalette(), qt_mac_createSystemPalette(), standardPalette(), QGtk3Storage::standardPalette(), QStyle::standardPalette(), QQC2::QStyle::standardPalette(), QQuickFusionStyle::tabFrameColor(), and QAndroidPlatformTheme::updateStyle().
|
noexcept |
Returns the lightness color component of this color.
Definition at line 1860 of file qcolor.cpp.
References Hsl, Invalid, lightness(), qt_div_257(), and toHsl().
Referenced by QGtk3Interface::colorSchemeByColors(), lightness(), populateDarkSystemBasePalette(), qt_ensure_default_accent_color(), shouldApplyDarkFrame(), and toHsl().
|
noexcept |
Returns the lightness color component of this color.
Definition at line 1902 of file qcolor.cpp.
References Hsl, Invalid, lightnessF(), and toHsl().
Referenced by darkerShade(), lighterShade(), and lightnessF().
|
noexcept |
Returns the magenta color component of this color.
Definition at line 1926 of file qcolor.cpp.
References Cmyk, Invalid, magenta(), qt_div_257(), and toCmyk().
Referenced by magenta().
|
noexcept |
Returns the magenta color component of this color.
Definition at line 1975 of file qcolor.cpp.
References Cmyk, Invalid, magentaF(), and toCmyk().
Referenced by magentaF().
QString QColor::name | ( | NameFormat | format = HexRgb | ) | const |
Returns the name of the color in the specified format.
Definition at line 834 of file qcolor.cpp.
References HexArgb, HexRgb, QString::number(), Q_INT64_C, rgba(), and QString::right().
Referenced by QTextMarkdownImporter::cbEnterSpan(), QTextMarkdownImporter::cbLeaveSpan(), generateWavyPixmap(), main(), QWaylandQtTextInputMethod::sendInputMethodEvent(), and QTextOdfWriter::tableCellStyleElement().
QColor::operator QVariant | ( | ) | const |
Returns the color as a QVariant.
Definition at line 2922 of file qcolor.cpp.
References QVariant::fromValue().
|
noexcept |
Returns true
if this color has different color specification or component values from color; otherwise returns false
.
ExtendedRgb and Rgb specifications are considered matching in this context.
Definition at line 2915 of file qcolor.cpp.
References operator==().
|
noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Assigns a copy of color and returns a reference to this color.
Definition at line 2874 of file qcolor.cpp.
|
noexcept |
Returns true
if this color has the same color specification and component values as color; otherwise returns false
.
ExtendedRgb and Rgb specifications are considered matching in this context.
Definition at line 2887 of file qcolor.cpp.
References Hsl, Hsv, qFuzzyCompare(), and Rgb.
|
noexcept |
Returns the red color component of this color.
Definition at line 1528 of file qcolor.cpp.
References Invalid, qt_div_257(), red(), Rgb, and toRgb().
Referenced by cgColorForQColor(), QQC2_NAMESPACE::QMacStyle::drawComplexControl(), QMacStyle::drawComplexControl(), QQC2::QWindowsXPStyle::drawControl(), QWindowsVistaStyle::drawControl(), QQC2::QWindowsStyle::drawPrimitive(), QQuick3DParticleEmitter::emitParticle(), QuickTestResult::fuzzyCompare(), QCommonStyle::generatedIconPixmap(), QQC2::QCommonStyle::generatedIconPixmap(), QCommandLinkButtonPrivate::mergedColors(), QQuickFusionStyle::mergedColors(), mixColors(), QStaticTextPrivate::paintText(), qt_accentColor(), qt_graphicsItem_highlightSelected(), QQuickColorDialogImpl::red(), QQuickColorInputs::red(), red(), setBlue(), QCoreGraphicsPaintEnginePrivate::setFillBrush(), setGreen(), setRed(), and setRedF().
|
noexcept |
Returns the red color component of this color.
Definition at line 1611 of file qcolor.cpp.
References castF16(), ExtendedRgb, Invalid, redF(), Rgb, and toRgb().
Referenced by QRhiD3D11::beginPass(), QRhiGles2::beginPass(), QRhiVulkan::beginPass(), QRhiMetalData::createDefaultRenderPass(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QColorTransform::map(), redF(), setBlueF(), QPdfEngine::setBrush(), setGreenF(), QPdfEngine::setPen(), QQuick3DSceneRenderer::synchronize(), QQuickColorProvider::tint(), QQuickMultiEffectPrivate::updateColorizationColor(), QQuick3DRenderLayerHelpers::updateLayerNodeHelper(), QQuickMultiEffectPrivate::updateShadowColor(), and QT_BEGIN_NAMESPACE::QQuickShapeCurveMaterialShader::updateUniformData().
|
noexcept |
Returns the RGB value of the color.
The alpha value is opaque.
Definition at line 1439 of file qcolor.cpp.
References Invalid, qRgb(), qt_div_257(), Rgb, rgb(), and toRgb().
Referenced by QQuickFusionStyle::buttonColor(), QQuickShapeStrokeMaterial::compare(), QX11PlatformPixmap::createBitmapFromImage(), Viewer::createImage(), darkenPixmap(), QQC2_NAMESPACE::darkenPixmap(), QWin32PrintEngine::drawTextItem(), QX11PlatformPixmap::fill(), makeBitmap(), makeBitmapCompliantIfNeeded(), qt_xcb_XPixmapFromBitmap(), rgb(), QColorDialogPrivate::selectColor(), QPainter::setBackground(), QPainter::setPen(), QX11PaintEngine::updatePen(), and src_gui_painting_qcolor::wrapper().
|
noexcept |
Returns the RGB value of the color, including its alpha.
For an invalid color, the alpha value of the returned color is unspecified.
Definition at line 1376 of file qcolor.cpp.
References Invalid, qRgba(), qt_div_257(), Rgb, rgba(), and toRgb().
Referenced by QSGFlatColorMaterial::compare(), QPixmap::createMaskFromColor(), QX11PlatformPixmap::fill(), is_monochrome(), name(), QSvgIOHandler::read(), QPdfIOHandler::read(), ColorImageProvider::requestPixmap(), QRasterPlatformPixmap::resize(), rgba(), QPdfEngine::setBrush(), QQuickColorDialogImpl::setColor(), QQuickColorInputs::setColor(), QPdfEngine::setPen(), QMacStyle::styleHint(), QQC2_NAMESPACE::QMacStyle::styleHint(), QCommonStyle::styleHint(), QQC2::QCommonStyle::styleHint(), QWindowsDirect2DPaintEnginePrivate::to_d2d_brush(), QX11PaintEngine::updateBrush(), and QX11PaintEngine::updatePen().
|
noexcept |
Returns the RGB64 value of the color, including its alpha.
For an invalid color, the alpha value of the returned color is unspecified.
Definition at line 1408 of file qcolor.cpp.
References Invalid, qRgba64(), Rgb, rgba64(), and toRgb().
Referenced by rgba64().
|
noexcept |
Returns the HSV saturation color component of this color.
The color is implicitly converted to HSV.
Definition at line 1734 of file qcolor.cpp.
References hsvSaturation().
Referenced by QQuickFusionStyle::buttonColor(), QQC2::QStyleHelper::drawDial(), QQuickFusionStyle::highlightedOutline(), and hsvSaturation().
|
noexcept |
Returns the HSV saturation color component of this color.
The color is implicitly converted to HSV.
Definition at line 1796 of file qcolor.cpp.
References hsvSaturationF().
Referenced by darkerShade(), hsvSaturationF(), and lighterShade().
void QColor::setAlpha | ( | int | alpha | ) |
Sets the alpha of this color to alpha.
Integer alpha is specified in the range 0-255.
Definition at line 1481 of file qcolor.cpp.
References castF16(), ExtendedRgb, and QCOLOR_INT_RANGE_CHECK.
Referenced by QVideoTextureHelper::SubtitleLayout::draw(), QQC2::QStyleHelper::drawDial(), QQuickMaterialStyle::highlightedRippleColor(), QPagePreview::paintEvent(), placeHolderColor(), qt_fusionPalette(), qt_placeholder_from_text(), QVideoTextureHelper::SubtitleLayout::toImage(), QWizardPrivate::updatePalette(), and QPdfEngine::updateState().
void QColor::setAlphaF | ( | float | alpha | ) |
Sets the alpha of this color to alpha.
float alpha is specified in the range 0.0-1.0.
Definition at line 1511 of file qcolor.cpp.
References castF16(), ExtendedRgb, QCOLOR_REAL_RANGE_CHECK, and qRound().
Referenced by QQC2_NAMESPACE::QMacStyle::drawControl(), QMacStyle::drawControl(), QQC2::QStyleHelper::drawDial(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QWidgetPrivate::drawWidget(), QWindowsIntegration::setApplicationBadge(), and QQuickMaterialStyle::switchDisabledUncheckedHandleColor().
void QColor::setBlue | ( | int | blue | ) |
Sets the blue color component of this color to blue.
Integer components are specified in the range 0-255.
Definition at line 1597 of file qcolor.cpp.
References alpha(), green(), QCOLOR_INT_RANGE_CHECK, red(), Rgb, and setRgb().
Referenced by QCommandLinkButtonPrivate::mergedColors(), and QQuickFusionStyle::mergedColors().
void QColor::setBlueF | ( | float | blue | ) |
Sets the blue color component of this color to blue.
If blue lies outside the 0.0-1.0 range, the color model will be changed to ExtendedRgb
.
Definition at line 1690 of file qcolor.cpp.
References alphaF(), castF16(), ExtendedRgb, greenF(), qRound(), redF(), Rgb, and setRgbF().
void QColor::setCmyk | ( | int | c, |
int | m, | ||
int | y, | ||
int | k, | ||
int | a = 255 |
||
) |
Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e.
transparency).
All the values must be in the range 0-255.
Definition at line 2682 of file qcolor.cpp.
void QColor::setCmykF | ( | float | c, |
float | m, | ||
float | y, | ||
float | k, | ||
float | a = 1.0 |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e.
transparency).
All the values must be in the range 0.0-1.0.
Definition at line 2712 of file qcolor.cpp.
References Cmyk, qRound(), and qWarning.
Referenced by qt_mac_toQColor().
void QColor::setGreen | ( | int | green | ) |
Sets the green color component of this color to green.
Integer components are specified in the range 0-255.
Definition at line 1568 of file qcolor.cpp.
References alpha(), blue(), QCOLOR_INT_RANGE_CHECK, red(), Rgb, and setRgb().
Referenced by QCommandLinkButtonPrivate::mergedColors(), and QQuickFusionStyle::mergedColors().
void QColor::setGreenF | ( | float | green | ) |
Sets the green color component of this color to green.
If green lies outside the 0.0-1.0 range, the color model will be changed to ExtendedRgb
.
Definition at line 1660 of file qcolor.cpp.
References alphaF(), blueF(), castF16(), ExtendedRgb, qRound(), redF(), Rgb, and setRgbF().
void QColor::setHsl | ( | int | h, |
int | s, | ||
int | l, | ||
int | a = 255 |
||
) |
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.
Definition at line 1215 of file qcolor.cpp.
Referenced by QQuickFusionStyle::highlightedOutline().
void QColor::setHslF | ( | float | h, |
float | s, | ||
float | l, | ||
float | a = 1.0 |
||
) |
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.
Definition at line 1185 of file qcolor.cpp.
References Hsl, qRound(), and qWarning.
Referenced by darkerShade(), and lighterShade().
void QColor::setHsv | ( | int | h, |
int | s, | ||
int | v, | ||
int | a = 255 |
||
) |
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha component of the HSV color.
The saturation, value and alpha-channel values must be in the range 0-255, and the hue value must be greater than -1.
Definition at line 1099 of file qcolor.cpp.
Referenced by QQuickFusionStyle::buttonColor(), darkenPixmap(), QQC2_NAMESPACE::darkenPixmap(), QQC2::QStyleHelper::drawDial(), and QQuickFusionDial::paint().
void QColor::setHsvF | ( | float | h, |
float | s, | ||
float | v, | ||
float | a = 1.0 |
||
) |
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha component of the HSV color.
All the values must be in the range 0.0-1.0.
Definition at line 1071 of file qcolor.cpp.
References Hsv, qRound(), and qWarning.
Referenced by QQC2_NAMESPACE::QMacStyle::drawControl(), and QMacStyle::drawControl().
void QColor::setRed | ( | int | red | ) |
Sets the red color component of this color to red.
Integer components are specified in the range 0-255.
Definition at line 1541 of file qcolor.cpp.
References alpha(), blue(), green(), QCOLOR_INT_RANGE_CHECK, red(), Rgb, and setRgb().
Referenced by QCommandLinkButtonPrivate::mergedColors(), and QQuickFusionStyle::mergedColors().
void QColor::setRedF | ( | float | red | ) |
Sets the red color component of this color to red.
If red lies outside the 0.0-1.0 range, the color model will be changed to ExtendedRgb
.
Definition at line 1628 of file qcolor.cpp.
References alphaF(), blueF(), castF16(), ExtendedRgb, greenF(), qRound(), red(), Rgb, and setRgbF().
void QColor::setRgb | ( | int | r, |
int | g, | ||
int | b, | ||
int | a = 255 |
||
) |
Sets the RGB value to r, g, b and the alpha value to a.
All the values must be in the range 0-255.
Definition at line 1350 of file qcolor.cpp.
Referenced by setBlue(), setGreen(), and setRed().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the RGB value to rgb.
The alpha value is set to opaque.
Definition at line 1451 of file qcolor.cpp.
References qBlue(), qGreen(), qRed(), rgb, and Rgb.
Sets the RGB value to rgba, including its alpha.
Definition at line 1388 of file qcolor.cpp.
References qAlpha(), qBlue(), qGreen(), qRed(), and Rgb.
Referenced by QAndroidStyle::AndroidColorDrawable::AndroidColorDrawable(), and QtPrivate::QColorShower::updateQColor().
Sets the RGB64 value to rgba, including its alpha.
Definition at line 1422 of file qcolor.cpp.
References Rgb.
void QColor::setRgbF | ( | float | r, |
float | g, | ||
float | b, | ||
float | a = 1.0 |
||
) |
Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency).
The alpha value must be in the range 0.0-1.0. If any of the other values are outside the range of 0.0-1.0 the color model will be set as ExtendedRgb
.
Definition at line 1317 of file qcolor.cpp.
References castF16(), ExtendedRgb, qRound(), qWarning, and Rgb.
Referenced by qt_mac_toQColor(), setBlueF(), setGreenF(), and setRedF().
|
inlinenoexcept |
Returns how the color was specified.
Definition at line 75 of file qcolor.h.
Referenced by QColorTransform::map().
|
noexcept |
Creates and returns a CMYK QColor based on this color.
Definition at line 2295 of file qcolor.cpp.
References Cmyk, isValid(), qMin(), qRound(), Rgb, toCmyk(), and toRgb().
Referenced by black(), blackF(), cyan(), cyanF(), getCmyk(), getCmykF(), magenta(), magentaF(), toCmyk(), yellow(), and yellowF().
|
noexcept |
Create and returns an extended RGB QColor based on this color.
Definition at line 2012 of file qcolor.cpp.
References castF16(), ExtendedRgb, isValid(), Rgb, toExtendedRgb(), and toRgb().
Referenced by toExtendedRgb().
|
noexcept |
Creates and returns an HSL QColor based on this color.
Definition at line 2239 of file qcolor.cpp.
References Hsl, hue(), isValid(), lightness(), Q_ASSERT_X, Q_MAX_3, Q_MIN_3, qFuzzyCompare(), qFuzzyIsNull(), qRound(), Rgb, toHsl(), and toRgb().
Referenced by getHsl(), getHslF(), hslHue(), hslHueF(), hslSaturation(), hslSaturationF(), lightness(), lightnessF(), and toHsl().
|
noexcept |
Creates and returns an HSV QColor based on this color.
Definition at line 2188 of file qcolor.cpp.
References Hsv, hue(), isValid(), Q_ASSERT_X, Q_MAX_3, Q_MIN_3, qFuzzyCompare(), qFuzzyIsNull(), qRound(), Rgb, toHsv(), and toRgb().
Referenced by QQuickFusionStyle::buttonColor(), QQC2::QStyleHelper::drawDial(), getHsv(), getHsvF(), QQuickFusionStyle::grooveColor(), QQuickFusionStyle::highlightedOutline(), hsvHue(), hsvHueF(), hsvSaturation(), hsvSaturationF(), QQuickFusionDial::paint(), QQuickFusionKnob::paint(), toHsv(), value(), and valueF().
|
noexcept |
Create and returns an RGB QColor based on this color.
Definition at line 2035 of file qcolor.cpp.
References castF16(), Cmyk, ExtendedRgb, Hsl, Hsv, i, isValid(), qBound(), qRound(), and Rgb.
Referenced by blue(), blueF(), QQuickPlatformColorDialog::currentColor(), QQC2::QWindowsXPStyle::drawControl(), QQC2::QWindowsStyle::drawPrimitive(), QQC2::QCommonStyle::generatedIconPixmap(), getRgb(), getRgbF(), green(), greenF(), QQuickImageParticle::initialize(), QColorTransform::map(), QQuickFusionStyle::mergedColors(), red(), redF(), rgb(), rgba(), rgba64(), toCmyk(), toExtendedRgb(), toHsl(), toHsv(), QSGDefaultGlyphNode::update(), and QSGRhiShaderEffectMaterialShader::updateUniformData().
|
noexcept |
Returns the value color component of this color.
Definition at line 1756 of file qcolor.cpp.
References Hsv, Invalid, qt_div_257(), toHsv(), and value().
Referenced by QQuickFusionStyle::buttonColor(), QQC2::QStyleHelper::drawDial(), QQuickFusionStyle::highlightedOutline(), QQuickFusionDial::paint(), QSvgIOHandler::setOption(), QPdfIOHandler::setOption(), value(), and QQuick3DParticleShapeDataUtils::writeValue().
|
noexcept |
Returns the value color component of this color.
Definition at line 1818 of file qcolor.cpp.
References Hsv, Invalid, toHsv(), and valueF().
Referenced by QQuick3DPhysicsHeightField::getSamples(), and valueF().
|
noexcept |
Returns the yellow color component of this color.
Definition at line 1938 of file qcolor.cpp.
References Cmyk, Invalid, qt_div_257(), toCmyk(), and yellow().
Referenced by yellow().
|
noexcept |
Returns the yellow color component of this color.
Definition at line 1987 of file qcolor.cpp.
References Cmyk, Invalid, toCmyk(), and yellowF().
Referenced by yellowF().
|
friend |
Writes the color to the stream.
Definition at line 2977 of file qcolor.cpp.
|
related |
Writes the color to the stream.
Definition at line 2977 of file qcolor.cpp.
|
friend |
Reads the color from the stream.
Definition at line 3013 of file qcolor.cpp.
|
related |
Reads the color from the stream.
Definition at line 3013 of file qcolor.cpp.
|
related |
Returns the alpha component of the ARGB quadruplet rgba.
Definition at line 27 of file qrgb.h.
References rgb.
|
related |
Returns the blue component of the ARGB quadruplet rgb.
Definition at line 24 of file qrgb.h.
References rgb.
|
related |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a gray value (0 to 255) from the given ARGB quadruplet rgb.
The gray value is calculated using the formula (R * 11 + G * 16 + B * 5)/32; the alpha-channel is ignored.
Definition at line 39 of file qrgb.h.
References qBlue(), qGray(), qGreen(), qRed(), and rgb.
|
related |
Returns the green component of the ARGB quadruplet rgb.
Definition at line 21 of file qrgb.h.
References rgb.
Converts an unpremultiplied ARGB quadruplet rgb into a premultiplied ARGB quadruplet.
Definition at line 45 of file qrgb.h.
References qAlpha().
|
related |
Returns the red component of the ARGB quadruplet rgb.
Definition at line 18 of file qrgb.h.
References rgb.
|
related |
|
related |
An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
The type also holds a value for the alpha-channel. The default alpha channel is ff
, i.e opaque. For more information, see the \l{QColor::Alpha-Blended Drawing}{Alpha-Blended Drawing} section.
Here are some examples of how QRgb values can be created:
|
related |
Converts a premultiplied ARGB quadruplet rgb into an unpremultiplied ARGB quadruplet.
Definition at line 60 of file qrgb.h.
References qAlpha(), qBlue(), qGreen(), qRed(), qRgba(), and qt_inv_premul_factor.