Struct qt_gui::QColor

source ·
#[repr(C)]
pub struct QColor { /* private fields */ }
Expand description

The QColor class provides colors based on RGB, HSV or CMYK values.

C++ class: QColor.

C++ documentation:

The QColor class provides colors based on RGB, HSV or CMYK values.

A color is normally specified in terms of RGB (red, green, and blue) components, but it is also possible to specify it in terms of HSV (hue, saturation, and value) and CMYK (cyan, magenta, yellow and black) components. In addition a color can be specified using a color name. The color name can be any of the SVG 1.0 color names.

RGBHSVCMYK

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 setNamedColor() function. The color names are taken from the SVG 1.0 color names. The name() function returns the name of the color in the format "#RRGGBB". Colors can also be set using setRgb(), setHsv() and setCmyk(). To get a lighter or darker color use the lighter() and darker() functions respectively.

The isValid() function indicates whether a QColor is legal at all. For example, a RGB color with RGB values out of range is illegal. For performance reasons, QColor mostly disregards illegal colors, and for that reason, the result of using an invalid color is undefined.

The color components can be retrieved individually, e.g with red(), hue() and cyan(). The values of the color components can also be retrieved in one go using the getRgb(), getHsv() and getCmyk() functions. Using the RGB color model, the color components can in addition be accessed with rgb().

There are several related non-members: QRgb is a typdef for an unsigned int representing the RGB value triplet (r, g, b). Note that it also can hold a value for the alpha-channel (for more information, see the Alpha-Blended Drawing section). The qRed(), qBlue() and qGreen() functions return the respective component of the given QRgb value, while the qRgb() and qRgba() functions create and return the QRgb triplet based on the given component values. Finally, the qAlpha() function returns the alpha component of the provided QRgb, and the qGray() function calculates and return a gray value based on the given value.

QColor is platform and device independent. The QColormap class maps the color to the hardware.

For more information about painting in general, see the Paint System documentation.

Implementations§

source§

impl QColor

source

pub unsafe fn alpha(&self) -> c_int

Returns the alpha color component of this color.

Calls C++ function: int QColor::alpha() const.

C++ documentation:

Returns the alpha color component of this color.

See also setAlpha(), alphaF(), and Alpha-Blended Drawing.

source

pub unsafe fn alpha_f(&self) -> c_double

Returns the alpha color component of this color.

Calls C++ function: double QColor::alphaF() const.

C++ documentation:

Returns the alpha color component of this color.

See also setAlphaF(), alpha(), and Alpha-Blended Drawing.

source

pub unsafe fn black(&self) -> c_int

Returns the black color component of this color.

Calls C++ function: int QColor::black() const.

C++ documentation:

Returns the black color component of this color.

See also blackF(), getCmyk(), and The CMYK Color Model.

source

pub unsafe fn black_f(&self) -> c_double

Returns the black color component of this color.

Calls C++ function: double QColor::blackF() const.

C++ documentation:

Returns the black color component of this color.

See also black(), getCmykF(), and The CMYK Color Model.

source

pub unsafe fn blue(&self) -> c_int

Returns the blue color component of this color.

Calls C++ function: int QColor::blue() const.

C++ documentation:

Returns the blue color component of this color.

See also setBlue(), blueF(), and getRgb().

source

pub unsafe fn blue_f(&self) -> c_double

Returns the blue color component of this color.

Calls C++ function: double QColor::blueF() const.

C++ documentation:

Returns the blue color component of this color.

See also setBlueF(), blue(), and getRgbF().

source

pub unsafe fn color_names() -> CppBox<QStringList>

Returns a QStringList containing the color names Qt knows about.

Calls C++ function: static QStringList QColor::colorNames().

C++ documentation:

Returns a QStringList containing the color names Qt knows about.

See also Predefined Colors.

source

pub unsafe fn convert_to(&self, color_spec: Spec) -> CppBox<QColor>

Creates a copy of this color in the format specified by colorSpec.

Calls C++ function: QColor QColor::convertTo(QColor::Spec colorSpec) const.

C++ documentation:

Creates a copy of this color in the format specified by colorSpec.

See also spec(), toCmyk(), toHsv(), toRgb(), and isValid().

source

pub unsafe fn copy_from_q_color( &self, arg1: impl CastInto<Ref<QColor>> ) -> Ref<QColor>

Assigns a copy of color to this color, and returns a reference to it.

Calls C++ function: QColor& QColor::operator=(const QColor& arg1).

C++ documentation:

Assigns a copy of color to this color, and returns a reference to it.

source

pub unsafe fn copy_from_global_color(&self, color: GlobalColor) -> Ref<QColor>

This is an overloaded function.

Calls C++ function: QColor& QColor::operator=(Qt::GlobalColor color).

C++ documentation:

This is an overloaded function.

Assigns a copy of color and returns a reference to this color.

source

pub unsafe fn cyan(&self) -> c_int

Returns the cyan color component of this color.

Calls C++ function: int QColor::cyan() const.

C++ documentation:

Returns the cyan color component of this color.

See also cyanF(), getCmyk(), and The CMYK Color Model.

source

pub unsafe fn cyan_f(&self) -> c_double

Returns the cyan color component of this color.

Calls C++ function: double QColor::cyanF() const.

C++ documentation:

Returns the cyan color component of this color.

See also cyan(), getCmykF(), and The CMYK Color Model.

source

pub unsafe fn dark_1a(&self, f: c_int) -> CppBox<QColor>

Use darker(factor) instead.

Calls C++ function: QColor QColor::dark(int f = …) const.

C++ documentation:

Use darker(factor) instead.

source

pub unsafe fn dark_0a(&self) -> CppBox<QColor>

Use darker(factor) instead.

Calls C++ function: QColor QColor::dark() const.

C++ documentation:

Use darker(factor) instead.

source

pub unsafe fn darker_1a(&self, f: c_int) -> CppBox<QColor>

Returns a darker (or lighter) color, but does not change this object.

Calls C++ function: QColor QColor::darker(int f = …) const.

C++ documentation:

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 RGB color to HSV, divides the value (V) component by factor and converts the color back to RGB.

This function was introduced in Qt 4.3.

See also lighter() and isValid().

source

pub unsafe fn darker_0a(&self) -> CppBox<QColor>

Returns a darker (or lighter) color, but does not change this object.

Calls C++ function: QColor QColor::darker() const.

C++ documentation:

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 RGB color to HSV, divides the value (V) component by factor and converts the color back to RGB.

This function was introduced in Qt 4.3.

See also lighter() and isValid().

source

pub unsafe fn from_cmyk_5a( c: c_int, m: c_int, y: c_int, k: c_int, a: c_int ) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromCmyk(int c, int m, int y, int k, int a = …).

C++ documentation:

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.

See also toCmyk(), fromCmykF(), isValid(), and The CMYK Color Model.

source

pub unsafe fn from_cmyk_4a( c: c_int, m: c_int, y: c_int, k: c_int ) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromCmyk(int c, int m, int y, int k).

C++ documentation:

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.

See also toCmyk(), fromCmykF(), isValid(), and The CMYK Color Model.

source

pub unsafe fn from_cmyk_f_5a( c: c_double, m: c_double, y: c_double, k: c_double, a: c_double ) -> CppBox<QColor>

This is an overloaded function.

Calls C++ function: static QColor QColor::fromCmykF(double c, double m, double y, double k, double a = …).

C++ documentation:

This is an overloaded function.

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.

See also toCmyk(), fromCmyk(), isValid(), and The CMYK Color Model.

source

pub unsafe fn from_cmyk_f_4a( c: c_double, m: c_double, y: c_double, k: c_double ) -> CppBox<QColor>

This is an overloaded function.

Calls C++ function: static QColor QColor::fromCmykF(double c, double m, double y, double k).

C++ documentation:

This is an overloaded function.

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.

See also toCmyk(), fromCmyk(), isValid(), and The CMYK Color Model.

source

pub unsafe fn from_hsl_4a( h: c_int, s: c_int, l: c_int, a: c_int ) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromHsl(int h, int s, int l, int a = …).

C++ documentation:

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.

This function was introduced in Qt 4.6.

See also toHsl(), fromHslF(), and isValid().

source

pub unsafe fn from_hsl_3a(h: c_int, s: c_int, l: c_int) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromHsl(int h, int s, int l).

C++ documentation:

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.

This function was introduced in Qt 4.6.

See also toHsl(), fromHslF(), and isValid().

source

pub unsafe fn from_hsl_f_4a( h: c_double, s: c_double, l: c_double, a: c_double ) -> CppBox<QColor>

This is an overloaded function.

Calls C++ function: static QColor QColor::fromHslF(double h, double s, double l, double a = …).

C++ documentation:

This is an overloaded function.

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.

This function was introduced in Qt 4.6.

See also toHsl(), fromHsl(), isValid(), and The HSL Color Model.

source

pub unsafe fn from_hsl_f_3a( h: c_double, s: c_double, l: c_double ) -> CppBox<QColor>

This is an overloaded function.

Calls C++ function: static QColor QColor::fromHslF(double h, double s, double l).

C++ documentation:

This is an overloaded function.

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.

This function was introduced in Qt 4.6.

See also toHsl(), fromHsl(), isValid(), and The HSL Color Model.

source

pub unsafe fn from_hsv_4a( h: c_int, s: c_int, v: c_int, a: c_int ) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromHsv(int h, int s, int v, int a = …).

C++ documentation:

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.

See also toHsv(), fromHsvF(), isValid(), and The HSV Color Model.

source

pub unsafe fn from_hsv_3a(h: c_int, s: c_int, v: c_int) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromHsv(int h, int s, int v).

C++ documentation:

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.

See also toHsv(), fromHsvF(), isValid(), and The HSV Color Model.

source

pub unsafe fn from_hsv_f_4a( h: c_double, s: c_double, v: c_double, a: c_double ) -> CppBox<QColor>

This is an overloaded function.

Calls C++ function: static QColor QColor::fromHsvF(double h, double s, double v, double a = …).

C++ documentation:

This is an overloaded function.

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.

See also toHsv(), fromHsv(), isValid(), and The HSV Color Model.

source

pub unsafe fn from_hsv_f_3a( h: c_double, s: c_double, v: c_double ) -> CppBox<QColor>

This is an overloaded function.

Calls C++ function: static QColor QColor::fromHsvF(double h, double s, double v).

C++ documentation:

This is an overloaded function.

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.

See also toHsv(), fromHsv(), isValid(), and The HSV Color Model.

source

pub unsafe fn from_rgb_1a(rgb: c_uint) -> CppBox<QColor>

Static convenience function that returns a QColor constructed from the given QRgb value rgb.

Calls C++ function: static QColor QColor::fromRgb(unsigned int rgb).

C++ documentation:

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.

See also fromRgba(), fromRgbF(), toRgb(), and isValid().

source

pub unsafe fn from_rgb_4a( r: c_int, g: c_int, b: c_int, a: c_int ) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromRgb(int r, int g, int b, int a = …).

C++ documentation:

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.

See also toRgb(), fromRgba64(), fromRgbF(), and isValid().

source

pub unsafe fn from_rgb_3a(r: c_int, g: c_int, b: c_int) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromRgb(int r, int g, int b).

C++ documentation:

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.

See also toRgb(), fromRgba64(), fromRgbF(), and isValid().

source

pub unsafe fn from_rgb_f_4a( r: c_double, g: c_double, b: c_double, a: c_double ) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromRgbF(double r, double g, double b, double a = …).

C++ documentation:

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.0-1.0.

See also fromRgb(), fromRgba64(), toRgb(), and isValid().

source

pub unsafe fn from_rgb_f_3a( r: c_double, g: c_double, b: c_double ) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromRgbF(double r, double g, double b).

C++ documentation:

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.0-1.0.

See also fromRgb(), fromRgba64(), toRgb(), and isValid().

source

pub unsafe fn from_rgba(rgba: c_uint) -> CppBox<QColor>

Static convenience function that returns a QColor constructed from the given QRgb value rgba.

Calls C++ function: static QColor QColor::fromRgba(unsigned int rgba).

C++ documentation:

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.

See also fromRgb(), fromRgba64(), and isValid().

source

pub unsafe fn from_rgba64_4a( r: c_ushort, g: c_ushort, b: c_ushort, a: c_ushort ) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromRgba64(unsigned short r, unsigned short g, unsigned short b, unsigned short a = …).

C++ documentation:

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).

This function was introduced in Qt 5.6.

See also fromRgb(), fromRgbF(), toRgb(), and isValid().

source

pub unsafe fn from_rgba64_1a( rgba: impl CastInto<Ref<QRgba64>> ) -> CppBox<QColor>

Static convenience function that returns a QColor constructed from the given QRgba64 value rgba64.

Calls C++ function: static QColor QColor::fromRgba64(QRgba64 rgba).

C++ documentation:

Static convenience function that returns a QColor constructed from the given QRgba64 value rgba64.

This function was introduced in Qt 5.6.

See also fromRgb(), fromRgbF(), toRgb(), and isValid().

source

pub unsafe fn from_rgba64_3a( r: c_ushort, g: c_ushort, b: c_ushort ) -> CppBox<QColor>

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).

Calls C++ function: static QColor QColor::fromRgba64(unsigned short r, unsigned short g, unsigned short b).

C++ documentation:

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).

This function was introduced in Qt 5.6.

See also fromRgb(), fromRgbF(), toRgb(), and isValid().

source

pub unsafe fn get_cmyk_5a_mut( &self, c: *mut c_int, m: *mut c_int, y: *mut c_int, k: *mut c_int, a: *mut c_int )

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.

Calls C++ function: void QColor::getCmyk(int* c, int* m, int* y, int* k, int* a = …).

C++ documentation:

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.

See also setCmyk() and The CMYK Color Model.

source

pub unsafe fn get_cmyk_4a_mut( &self, c: *mut c_int, m: *mut c_int, y: *mut c_int, k: *mut c_int )

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.

Calls C++ function: void QColor::getCmyk(int* c, int* m, int* y, int* k).

C++ documentation:

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.

See also setCmyk() and The CMYK Color Model.

source

pub unsafe fn get_cmyk_5a( &self, c: *mut c_int, m: *mut c_int, y: *mut c_int, k: *mut c_int, a: *mut c_int )

Available on cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Calls C++ function: void QColor::getCmyk(int* c, int* m, int* y, int* k, int* a = …) const.

C++ documentation:

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use the const overload instead.

source

pub unsafe fn get_cmyk_4a( &self, c: *mut c_int, m: *mut c_int, y: *mut c_int, k: *mut c_int )

Available on cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Calls C++ function: void QColor::getCmyk(int* c, int* m, int* y, int* k) const.

C++ documentation:

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use the const overload instead.

source

pub unsafe fn get_cmyk_f_5a_mut( &self, c: *mut c_double, m: *mut c_double, y: *mut c_double, k: *mut c_double, a: *mut c_double )

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.

Calls C++ function: void QColor::getCmykF(double* c, double* m, double* y, double* k, double* a = …).

C++ documentation:

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.

See also setCmykF() and The CMYK Color Model.

source

pub unsafe fn get_cmyk_f_4a_mut( &self, c: *mut c_double, m: *mut c_double, y: *mut c_double, k: *mut c_double )

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.

Calls C++ function: void QColor::getCmykF(double* c, double* m, double* y, double* k).

C++ documentation:

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.

See also setCmykF() and The CMYK Color Model.

source

pub unsafe fn get_cmyk_f_5a( &self, c: *mut c_double, m: *mut c_double, y: *mut c_double, k: *mut c_double, a: *mut c_double )

Available on cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Calls C++ function: void QColor::getCmykF(double* c, double* m, double* y, double* k, double* a = …) const.

C++ documentation:

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use the const overload instead.

source

pub unsafe fn get_cmyk_f_4a( &self, c: *mut c_double, m: *mut c_double, y: *mut c_double, k: *mut c_double )

Available on cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Calls C++ function: void QColor::getCmykF(double* c, double* m, double* y, double* k) const.

C++ documentation:

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use the const overload instead.

source

pub unsafe fn get_hsl_4a( &self, h: *mut c_int, s: *mut c_int, l: *mut c_int, a: *mut c_int )

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.

Calls C++ function: void QColor::getHsl(int* h, int* s, int* l, int* a = …) const.

C++ documentation:

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.

This function was introduced in Qt 4.6.

See also setHsl().

source

pub unsafe fn get_hsl_3a(&self, h: *mut c_int, s: *mut c_int, l: *mut c_int)

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.

Calls C++ function: void QColor::getHsl(int* h, int* s, int* l) const.

C++ documentation:

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.

This function was introduced in Qt 4.6.

See also setHsl().

source

pub unsafe fn get_hsl_f_4a( &self, h: *mut c_double, s: *mut c_double, l: *mut c_double, a: *mut c_double )

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.

Calls C++ function: void QColor::getHslF(double* h, double* s, double* l, double* a = …) const.

C++ documentation:

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.

This function was introduced in Qt 4.6.

See also setHsl().

source

pub unsafe fn get_hsl_f_3a( &self, h: *mut c_double, s: *mut c_double, l: *mut c_double )

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.

Calls C++ function: void QColor::getHslF(double* h, double* s, double* l) const.

C++ documentation:

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.

This function was introduced in Qt 4.6.

See also setHsl().

source

pub unsafe fn get_hsv_4a( &self, h: *mut c_int, s: *mut c_int, v: *mut c_int, a: *mut c_int )

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.

Calls C++ function: void QColor::getHsv(int* h, int* s, int* v, int* a = …) const.

C++ documentation:

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.

See also setHsv() and The HSV Color Model.

source

pub unsafe fn get_hsv_3a(&self, h: *mut c_int, s: *mut c_int, v: *mut c_int)

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.

Calls C++ function: void QColor::getHsv(int* h, int* s, int* v) const.

C++ documentation:

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.

See also setHsv() and The HSV Color Model.

source

pub unsafe fn get_hsv_f_4a( &self, h: *mut c_double, s: *mut c_double, v: *mut c_double, a: *mut c_double )

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.

Calls C++ function: void QColor::getHsvF(double* h, double* s, double* v, double* a = …) const.

C++ documentation:

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.

See also setHsv() and The HSV Color Model.

source

pub unsafe fn get_hsv_f_3a( &self, h: *mut c_double, s: *mut c_double, v: *mut c_double )

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.

Calls C++ function: void QColor::getHsvF(double* h, double* s, double* v) const.

C++ documentation:

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.

See also setHsv() and The HSV Color Model.

source

pub unsafe fn get_rgb_4a( &self, r: *mut c_int, g: *mut c_int, b: *mut c_int, a: *mut c_int )

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.

Calls C++ function: void QColor::getRgb(int* r, int* g, int* b, int* a = …) const.

C++ documentation:

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.

See also rgb() and setRgb().

source

pub unsafe fn get_rgb_3a(&self, r: *mut c_int, g: *mut c_int, b: *mut c_int)

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.

Calls C++ function: void QColor::getRgb(int* r, int* g, int* b) const.

C++ documentation:

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.

See also rgb() and setRgb().

source

pub unsafe fn get_rgb_f_4a( &self, r: *mut c_double, g: *mut c_double, b: *mut c_double, a: *mut c_double )

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.

Calls C++ function: void QColor::getRgbF(double* r, double* g, double* b, double* a = …) const.

C++ documentation:

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.

See also rgb() and setRgb().

source

pub unsafe fn get_rgb_f_3a( &self, r: *mut c_double, g: *mut c_double, b: *mut c_double )

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.

Calls C++ function: void QColor::getRgbF(double* r, double* g, double* b) const.

C++ documentation:

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.

See also rgb() and setRgb().

source

pub unsafe fn green(&self) -> c_int

Returns the green color component of this color.

Calls C++ function: int QColor::green() const.

C++ documentation:

Returns the green color component of this color.

See also setGreen(), greenF(), and getRgb().

source

pub unsafe fn green_f(&self) -> c_double

Returns the green color component of this color.

Calls C++ function: double QColor::greenF() const.

C++ documentation:

Returns the green color component of this color.

See also setGreenF(), green(), and getRgbF().

source

pub unsafe fn hsl_hue(&self) -> c_int

Returns the hue color component of this color.

Calls C++ function: int QColor::hslHue() const.

C++ documentation:

Returns the hue color component of this color.

This function was introduced in Qt 4.6.

See also getHslF() and getHsl().

source

pub unsafe fn hsl_hue_f(&self) -> c_double

Returns the hue color component of this color.

Calls C++ function: double QColor::hslHueF() const.

C++ documentation:

Returns the hue color component of this color.

This function was introduced in Qt 4.6.

See also hue() and getHslF().

source

pub unsafe fn hsl_saturation(&self) -> c_int

Returns the saturation color component of this color.

Calls C++ function: int QColor::hslSaturation() const.

C++ documentation:

Returns the saturation color component of this color.

This function was introduced in Qt 4.6.

See also saturationF(), getHsv(), and The HSV Color Model.

source

pub unsafe fn hsl_saturation_f(&self) -> c_double

Returns the saturation color component of this color.

Calls C++ function: double QColor::hslSaturationF() const.

C++ documentation:

Returns the saturation color component of this color.

This function was introduced in Qt 4.6.

See also saturationF() and getHslF().

source

pub unsafe fn hsv_hue(&self) -> c_int

Returns the hue color component of this color.

Calls C++ function: int QColor::hsvHue() const.

C++ documentation:

Returns the hue color component of this color.

See also hueF(), getHsv(), and The HSV Color Model.

source

pub unsafe fn hsv_hue_f(&self) -> c_double

Returns the hue color component of this color.

Calls C++ function: double QColor::hsvHueF() const.

C++ documentation:

Returns the hue color component of this color.

See also hue(), getHsvF(), and The HSV Color Model.

source

pub unsafe fn hsv_saturation(&self) -> c_int

Returns the saturation color component of this color.

Calls C++ function: int QColor::hsvSaturation() const.

C++ documentation:

Returns the saturation color component of this color.

See also saturationF(), getHsv(), and The HSV Color Model.

source

pub unsafe fn hsv_saturation_f(&self) -> c_double

Returns the saturation color component of this color.

Calls C++ function: double QColor::hsvSaturationF() const.

C++ documentation:

Returns the saturation color component of this color.

See also saturation(), getHsvF(), and The HSV Color Model.

source

pub unsafe fn hue(&self) -> c_int

Returns the hue color component of this color.

Calls C++ function: int QColor::hue() const.

C++ documentation:

Returns the hue color component of this color.

The color is implicitly converted to HSV.

See also hsvHue(), hueF(), getHsv(), and The HSV Color Model.

source

pub unsafe fn hue_f(&self) -> c_double

Returns the hue color component of this color.

Calls C++ function: double QColor::hueF() const.

C++ documentation:

Returns the hue color component of this color.

The color is implicitly converted to HSV.

See also hsvHueF(), hue(), getHsvF(), and The HSV Color Model.

source

pub unsafe fn is_valid(&self) -> bool

Returns true if the color is valid; otherwise returns false.

Calls C++ function: bool QColor::isValid() const.

C++ documentation:

Returns true if the color is valid; otherwise returns false.

source

pub unsafe fn is_valid_color_q_string(name: impl CastInto<Ref<QString>>) -> bool

Returns true if the name is a valid color name and can be used to construct a valid QColor object, otherwise returns false.

Calls C++ function: static bool QColor::isValidColor(const QString& name).

C++ documentation:

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 setNamedColor().

This function was introduced in Qt 4.7.

See also setNamedColor().

source

pub unsafe fn is_valid_color_q_latin1_string( arg1: impl CastInto<Ref<QLatin1String>> ) -> bool

This is an overloaded function.

Calls C++ function: static bool QColor::isValidColor(QLatin1String arg1).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.8.

source

pub unsafe fn is_valid_color_q_string_view( arg1: impl CastInto<Ref<QStringView>> ) -> bool

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: static bool QColor::isValidColor(QStringView arg1).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.10.

source

pub unsafe fn light_1a(&self, f: c_int) -> CppBox<QColor>

Use lighter(factor) instead.

Calls C++ function: QColor QColor::light(int f = …) const.

C++ documentation:

Use lighter(factor) instead.

source

pub unsafe fn light_0a(&self) -> CppBox<QColor>

Use lighter(factor) instead.

Calls C++ function: QColor QColor::light() const.

C++ documentation:

Use lighter(factor) instead.

source

pub unsafe fn lighter_1a(&self, f: c_int) -> CppBox<QColor>

Returns a lighter (or darker) color, but does not change this object.

Calls C++ function: QColor QColor::lighter(int f = …) const.

C++ documentation:

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 RGB color to HSV, multiplies the value (V) component by factor and converts the color back to RGB.

This function was introduced in Qt 4.3.

See also darker() and isValid().

source

pub unsafe fn lighter_0a(&self) -> CppBox<QColor>

Returns a lighter (or darker) color, but does not change this object.

Calls C++ function: QColor QColor::lighter() const.

C++ documentation:

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 RGB color to HSV, multiplies the value (V) component by factor and converts the color back to RGB.

This function was introduced in Qt 4.3.

See also darker() and isValid().

source

pub unsafe fn lightness(&self) -> c_int

Returns the lightness color component of this color.

Calls C++ function: int QColor::lightness() const.

C++ documentation:

Returns the lightness color component of this color.

This function was introduced in Qt 4.6.

See also lightnessF() and getHsl().

source

pub unsafe fn lightness_f(&self) -> c_double

Returns the lightness color component of this color.

Calls C++ function: double QColor::lightnessF() const.

C++ documentation:

Returns the lightness color component of this color.

This function was introduced in Qt 4.6.

See also value() and getHslF().

source

pub unsafe fn magenta(&self) -> c_int

Returns the magenta color component of this color.

Calls C++ function: int QColor::magenta() const.

C++ documentation:

Returns the magenta color component of this color.

See also magentaF(), getCmyk(), and The CMYK Color Model.

source

pub unsafe fn magenta_f(&self) -> c_double

Returns the magenta color component of this color.

Calls C++ function: double QColor::magentaF() const.

C++ documentation:

Returns the magenta color component of this color.

See also magenta(), getCmykF(), and The CMYK Color Model.

source

pub unsafe fn name_0a(&self) -> CppBox<QString>

Returns the name of the color in the format "#RRGGBB"; i.e. a "#" character followed by three two-digit hexadecimal numbers.

Calls C++ function: QString QColor::name() const.

C++ documentation:

Returns the name of the color in the format “#RRGGBB”; i.e. a “#” character followed by three two-digit hexadecimal numbers.

See also setNamedColor().

source

pub unsafe fn name_1a(&self, format: NameFormat) -> CppBox<QString>

Returns the name of the color in the specified format.

Calls C++ function: QString QColor::name(QColor::NameFormat format) const.

C++ documentation:

Returns the name of the color in the specified format.

This function was introduced in Qt 5.2.

See also setNamedColor() and NameFormat.

source

pub unsafe fn new() -> CppBox<QColor>

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.

Calls C++ function: [constructor] void QColor::QColor().

C++ documentation:

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.

See also isValid().

source

pub unsafe fn from_global_color(color: GlobalColor) -> CppBox<QColor>

This is an overloaded function.

Calls C++ function: [constructor] void QColor::QColor(Qt::GlobalColor color).

C++ documentation:

This is an overloaded function.

Constructs a new color with a color value of color.

See also isValid() and Predefined Colors.

source

pub unsafe fn from_4_int( r: c_int, g: c_int, b: c_int, a: c_int ) -> CppBox<QColor>

Constructs a color with the RGB value r, g, b, and the alpha-channel (transparency) value of a.

Calls C++ function: [constructor] void QColor::QColor(int r, int g, int b, int a = …).

C++ documentation:

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.

See also setRgba() and isValid().

source

pub unsafe fn from_uint(rgb: c_uint) -> CppBox<QColor>

Constructs a color with the value color. The alpha component is ignored and set to solid.

Calls C++ function: [constructor] void QColor::QColor(unsigned int rgb).

C++ documentation:

Constructs a color with the value color. The alpha component is ignored and set to solid.

See also fromRgb() and isValid().

source

pub unsafe fn from_q_rgba64( rgba64: impl CastInto<Ref<QRgba64>> ) -> CppBox<QColor>

Constructs a color with the value rgba64.

Calls C++ function: [constructor] void QColor::QColor(QRgba64 rgba64).

C++ documentation:

Constructs a color with the value rgba64.

This function was introduced in Qt 5.6.

See also fromRgba64().

source

pub unsafe fn from_q_string(name: impl CastInto<Ref<QString>>) -> CppBox<QColor>

Constructs a named color in the same way as setNamedColor() using the given name.

Calls C++ function: [constructor] void QColor::QColor(const QString& name).

C++ documentation:

Constructs a named color in the same way as setNamedColor() using the given name.

The color is left invalid if the name cannot be parsed.

See also setNamedColor(), name(), and isValid().

source

pub unsafe fn from_char(aname: *const c_char) -> CppBox<QColor>

Constructs a named color in the same way as setNamedColor() using the given name.

Calls C++ function: [constructor] void QColor::QColor(const char* aname).

C++ documentation:

Constructs a named color in the same way as setNamedColor() using the given name.

This is an overloaded function.

See also setNamedColor(), name(), and isValid().

source

pub unsafe fn from_q_latin1_string( name: impl CastInto<Ref<QLatin1String>> ) -> CppBox<QColor>

Constructs a named color in the same way as setNamedColor() using the given name.

Calls C++ function: [constructor] void QColor::QColor(QLatin1String name).

C++ documentation:

Constructs a named color in the same way as setNamedColor() using the given name.

This is an overloaded function.

This function was introduced in Qt 5.8.

See also setNamedColor(), name(), and isValid().

source

pub unsafe fn from_spec(spec: Spec) -> CppBox<QColor>

Calls C++ function: [constructor] void QColor::QColor(QColor::Spec spec).

source

pub unsafe fn from_3_int(r: c_int, g: c_int, b: c_int) -> CppBox<QColor>

Constructs a color with the RGB value r, g, b, and the alpha-channel (transparency) value of a.

Calls C++ function: [constructor] void QColor::QColor(int r, int g, int b).

C++ documentation:

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.

See also setRgba() and isValid().

source

pub unsafe fn from_q_string_view( name: impl CastInto<Ref<QStringView>> ) -> CppBox<QColor>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Default constructs an instance of QColor.

Calls C++ function: [constructor] void QColor::QColor(QStringView name).

C++ documentation:

Default constructs an instance of QColor.

source

pub unsafe fn from_spec5_ushort( spec: Spec, a1: c_ushort, a2: c_ushort, a3: c_ushort, a4: c_ushort, a5: c_ushort ) -> CppBox<QColor>

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: [constructor] void QColor::QColor(QColor::Spec spec, unsigned short a1, unsigned short a2, unsigned short a3, unsigned short a4, unsigned short a5 = …).

source

pub unsafe fn from_spec4_ushort( spec: Spec, a1: c_ushort, a2: c_ushort, a3: c_ushort, a4: c_ushort ) -> CppBox<QColor>

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: [constructor] void QColor::QColor(QColor::Spec spec, unsigned short a1, unsigned short a2, unsigned short a3, unsigned short a4).

source

pub unsafe fn new_copy(color: impl CastInto<Ref<QColor>>) -> CppBox<QColor>

Constructs a color that is a copy of color.

Calls C++ function: [constructor] void QColor::QColor(const QColor& color).

C++ documentation:

Constructs a color that is a copy of color.

See also isValid().

source

pub unsafe fn red(&self) -> c_int

Returns the red color component of this color.

Calls C++ function: int QColor::red() const.

C++ documentation:

Returns the red color component of this color.

See also setRed(), redF(), and getRgb().

source

pub unsafe fn red_f(&self) -> c_double

Returns the red color component of this color.

Calls C++ function: double QColor::redF() const.

C++ documentation:

Returns the red color component of this color.

See also setRedF(), red(), and getRgbF().

source

pub unsafe fn rgb(&self) -> c_uint

Returns the RGB value of the color. The alpha value is opaque.

Calls C++ function: unsigned int QColor::rgb() const.

C++ documentation:

Returns the RGB value of the color. The alpha value is opaque.

See also setRgb(), getRgb(), and rgba().

source

pub unsafe fn rgba(&self) -> c_uint

Returns the RGB value of the color, including its alpha.

Calls C++ function: unsigned int QColor::rgba() const.

C++ documentation:

Returns the RGB value of the color, including its alpha.

For an invalid color, the alpha value of the returned color is unspecified.

See also setRgba(), rgb(), and rgba64().

source

pub unsafe fn rgba64(&self) -> CppBox<QRgba64>

Returns the RGB64 value of the color, including its alpha.

Calls C++ function: QRgba64 QColor::rgba64() const.

C++ documentation:

Returns the RGB64 value of the color, including its alpha.

For an invalid color, the alpha value of the returned color is unspecified.

This function was introduced in Qt 5.6.

See also setRgba64(), rgba(), and rgb().

source

pub unsafe fn saturation(&self) -> c_int

Returns the saturation color component of this color.

Calls C++ function: int QColor::saturation() const.

C++ documentation:

Returns the saturation color component of this color.

The color is implicitly converted to HSV.

See also hsvSaturation(), saturationF(), getHsv(), and The HSV Color Model.

source

pub unsafe fn saturation_f(&self) -> c_double

Returns the saturation color component of this color.

Calls C++ function: double QColor::saturationF() const.

C++ documentation:

Returns the saturation color component of this color.

The color is implicitly converted to HSV.

See also hsvSaturationF(), saturation(), getHsvF(), and The HSV Color Model.

source

pub unsafe fn set_alpha(&self, alpha: c_int)

Sets the alpha of this color to alpha. Integer alpha is specified in the range 0-255.

Calls C++ function: void QColor::setAlpha(int alpha).

C++ documentation:

Sets the alpha of this color to alpha. Integer alpha is specified in the range 0-255.

See also alpha(), alphaF(), and Alpha-Blended Drawing.

source

pub unsafe fn set_alpha_f(&self, alpha: c_double)

Sets the alpha of this color to alpha. qreal alpha is specified in the range 0.0-1.0.

Calls C++ function: void QColor::setAlphaF(double alpha).

C++ documentation:

Sets the alpha of this color to alpha. qreal alpha is specified in the range 0.0-1.0.

See also alphaF(), alpha(), and Alpha-Blended Drawing.

source

pub unsafe fn set_blue(&self, blue: c_int)

Sets the blue color component of this color to blue. Integer components are specified in the range 0-255.

Calls C++ function: void QColor::setBlue(int blue).

C++ documentation:

Sets the blue color component of this color to blue. Integer components are specified in the range 0-255.

See also blue(), blueF(), and setRgb().

source

pub unsafe fn set_blue_f(&self, blue: c_double)

Sets the blue color component of this color to blue. Float components are specified in the range 0.0-1.0.

Calls C++ function: void QColor::setBlueF(double blue).

C++ documentation:

Sets the blue color component of this color to blue. Float components are specified in the range 0.0-1.0.

See also blueF(), blue(), and setRgbF().

source

pub unsafe fn set_cmyk_5a( &self, c: c_int, m: c_int, y: c_int, k: c_int, a: c_int )

Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e. transparency).

Calls C++ function: void QColor::setCmyk(int c, int m, int y, int k, int a = …).

C++ documentation:

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.

See also getCmyk(), setCmykF(), and The CMYK Color Model.

source

pub unsafe fn set_cmyk_4a(&self, c: c_int, m: c_int, y: c_int, k: c_int)

Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e. transparency).

Calls C++ function: void QColor::setCmyk(int c, int m, int y, int k).

C++ documentation:

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.

See also getCmyk(), setCmykF(), and The CMYK Color Model.

source

pub unsafe fn set_cmyk_f_5a( &self, c: c_double, m: c_double, y: c_double, k: c_double, a: c_double )

This is an overloaded function.

Calls C++ function: void QColor::setCmykF(double c, double m, double y, double k, double a = …).

C++ documentation:

This is an overloaded function.

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.

See also getCmykF(), setCmyk(), and The CMYK Color Model.

source

pub unsafe fn set_cmyk_f_4a( &self, c: c_double, m: c_double, y: c_double, k: c_double )

This is an overloaded function.

Calls C++ function: void QColor::setCmykF(double c, double m, double y, double k).

C++ documentation:

This is an overloaded function.

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.

See also getCmykF(), setCmyk(), and The CMYK Color Model.

source

pub unsafe fn set_green(&self, green: c_int)

Sets the green color component of this color to green. Integer components are specified in the range 0-255.

Calls C++ function: void QColor::setGreen(int green).

C++ documentation:

Sets the green color component of this color to green. Integer components are specified in the range 0-255.

See also green(), greenF(), and setRgb().

source

pub unsafe fn set_green_f(&self, green: c_double)

Sets the green color component of this color to green. Float components are specified in the range 0.0-1.0.

Calls C++ function: void QColor::setGreenF(double green).

C++ documentation:

Sets the green color component of this color to green. Float components are specified in the range 0.0-1.0.

See also greenF(), green(), and setRgbF().

source

pub unsafe fn set_hsl_4a(&self, h: c_int, s: c_int, l: c_int, a: c_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.

Calls C++ function: void QColor::setHsl(int h, int s, int l, int a = …).

C++ documentation:

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.

This function was introduced in Qt 4.6.

See also getHsl() and setHslF().

source

pub unsafe fn set_hsl_3a(&self, h: c_int, s: c_int, l: c_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.

Calls C++ function: void QColor::setHsl(int h, int s, int l).

C++ documentation:

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.

This function was introduced in Qt 4.6.

See also getHsl() and setHslF().

source

pub unsafe fn set_hsl_f_4a( &self, h: c_double, s: c_double, l: c_double, a: c_double )

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.

Calls C++ function: void QColor::setHslF(double h, double s, double l, double a = …).

C++ documentation:

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.

This function was introduced in Qt 4.6.

See also getHslF() and setHsl().

source

pub unsafe fn set_hsl_f_3a(&self, h: c_double, s: c_double, l: c_double)

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.

Calls C++ function: void QColor::setHslF(double h, double s, double l).

C++ documentation:

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.

This function was introduced in Qt 4.6.

See also getHslF() and setHsl().

source

pub unsafe fn set_hsv_4a(&self, h: c_int, s: c_int, v: c_int, a: c_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.

Calls C++ function: void QColor::setHsv(int h, int s, int v, int a = …).

C++ documentation:

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.

See also getHsv(), setHsvF(), and The HSV Color Model.

source

pub unsafe fn set_hsv_3a(&self, h: c_int, s: c_int, v: c_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.

Calls C++ function: void QColor::setHsv(int h, int s, int v).

C++ documentation:

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.

See also getHsv(), setHsvF(), and The HSV Color Model.

source

pub unsafe fn set_hsv_f_4a( &self, h: c_double, s: c_double, v: c_double, a: c_double )

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.

Calls C++ function: void QColor::setHsvF(double h, double s, double v, double a = …).

C++ documentation:

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.

See also getHsvF(), setHsv(), and The HSV Color Model.

source

pub unsafe fn set_hsv_f_3a(&self, h: c_double, s: c_double, v: c_double)

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.

Calls C++ function: void QColor::setHsvF(double h, double s, double v).

C++ documentation:

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.

See also getHsvF(), setHsv(), and The HSV Color Model.

source

pub unsafe fn set_named_color_q_string(&self, name: impl CastInto<Ref<QString>>)

Sets the RGB value of this QColor to name, which may be in one of these formats:

Calls C++ function: void QColor::setNamedColor(const QString& name).

C++ documentation:

Sets the RGB value of this QColor to name, which may be in one of these formats:

  • #RGB (each of R, G, and B is a single hex digit)
  • #RRGGBB
  • #AARRGGBB (Since 5.2)
  • #RRRGGGBBB
  • #RRRRGGGGBBBB
  • A name from the list of colors defined in the list of SVG color keyword names provided by the World Wide Web Consortium; for example, "steelblue" or "gainsboro". These color names work on all platforms. Note that these color names are not the same as defined by the Qt::GlobalColor enums, e.g. "green" and Qt::green does not refer to the same color.
  • transparent - representing the absence of a color.

The color is invalid if name cannot be parsed.

See also QColor(), name(), and isValid().

source

pub unsafe fn set_named_color_q_latin1_string( &self, name: impl CastInto<Ref<QLatin1String>> )

This is an overloaded function.

Calls C++ function: void QColor::setNamedColor(QLatin1String name).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.8.

source

pub unsafe fn set_named_color_q_string_view( &self, name: impl CastInto<Ref<QStringView>> )

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: void QColor::setNamedColor(QStringView name).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.10.

source

pub unsafe fn set_red(&self, red: c_int)

Sets the red color component of this color to red. Integer components are specified in the range 0-255.

Calls C++ function: void QColor::setRed(int red).

C++ documentation:

Sets the red color component of this color to red. Integer components are specified in the range 0-255.

See also red(), redF(), and setRgb().

source

pub unsafe fn set_red_f(&self, red: c_double)

Sets the red color component of this color to red. Float components are specified in the range 0.0-1.0.

Calls C++ function: void QColor::setRedF(double red).

C++ documentation:

Sets the red color component of this color to red. Float components are specified in the range 0.0-1.0.

See also redF(), red(), and setRgbF().

source

pub unsafe fn set_rgb_4a(&self, r: c_int, g: c_int, b: c_int, a: c_int)

Sets the RGB value to r, g, b and the alpha value to a.

Calls C++ function: void QColor::setRgb(int r, int g, int b, int a = …).

C++ documentation:

Sets the RGB value to r, g, b and the alpha value to a.

All the values must be in the range 0-255.

See also rgb(), getRgb(), and setRgbF().

source

pub unsafe fn set_rgb_1a(&self, rgb: c_uint)

This is an overloaded function.

Calls C++ function: void QColor::setRgb(unsigned int rgb).

C++ documentation:

This is an overloaded function.

Sets the RGB value to rgb. The alpha value is set to opaque.

source

pub unsafe fn set_rgb_3a(&self, r: c_int, g: c_int, b: c_int)

Sets the RGB value to r, g, b and the alpha value to a.

Calls C++ function: void QColor::setRgb(int r, int g, int b).

C++ documentation:

Sets the RGB value to r, g, b and the alpha value to a.

All the values must be in the range 0-255.

See also rgb(), getRgb(), and setRgbF().

source

pub unsafe fn set_rgb_f_4a( &self, r: c_double, g: c_double, b: c_double, a: c_double )

Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency).

Calls C++ function: void QColor::setRgbF(double r, double g, double b, double a = …).

C++ documentation:

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.

See also rgb(), getRgbF(), and setRgb().

source

pub unsafe fn set_rgb_f_3a(&self, r: c_double, g: c_double, b: c_double)

Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency).

Calls C++ function: void QColor::setRgbF(double r, double g, double b).

C++ documentation:

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.

See also rgb(), getRgbF(), and setRgb().

source

pub unsafe fn set_rgba(&self, rgba: c_uint)

Sets the RGB value to rgba, including its alpha.

Calls C++ function: void QColor::setRgba(unsigned int rgba).

C++ documentation:

Sets the RGB value to rgba, including its alpha.

See also rgba(), rgb(), and setRgba64().

source

pub unsafe fn set_rgba64(&self, rgba: impl CastInto<Ref<QRgba64>>)

Sets the RGB64 value to rgba, including its alpha.

Calls C++ function: void QColor::setRgba64(QRgba64 rgba).

C++ documentation:

Sets the RGB64 value to rgba, including its alpha.

This function was introduced in Qt 5.6.

See also setRgba() and rgba64().

source

pub unsafe fn spec(&self) -> Spec

Returns how the color was specified.

Calls C++ function: QColor::Spec QColor::spec() const.

C++ documentation:

Returns how the color was specified.

See also Spec and convertTo().

source

pub unsafe fn to_cmyk(&self) -> CppBox<QColor>

Creates and returns a CMYK QColor based on this color.

Calls C++ function: QColor QColor::toCmyk() const.

C++ documentation:

Creates and returns a CMYK QColor based on this color.

See also fromCmyk(), convertTo(), isValid(), and The CMYK Color Model.

source

pub unsafe fn to_extended_rgb(&self) -> CppBox<QColor>

Available on cpp_lib_version="5.14.0" only.

Create and returns an extended RGB QColor based on this color.

Calls C++ function: QColor QColor::toExtendedRgb() const.

C++ documentation:

Create and returns an extended RGB QColor based on this color.

This function was introduced in Qt 5.14.

See also toRgb and convertTo().

source

pub unsafe fn to_hsl(&self) -> CppBox<QColor>

Creates and returns an HSL QColor based on this color.

Calls C++ function: QColor QColor::toHsl() const.

C++ documentation:

Creates and returns an HSL QColor based on this color.

See also fromHsl(), convertTo(), and isValid().

source

pub unsafe fn to_hsv(&self) -> CppBox<QColor>

Creates and returns an HSV QColor based on this color.

Calls C++ function: QColor QColor::toHsv() const.

C++ documentation:

Creates and returns an HSV QColor based on this color.

See also fromHsv(), convertTo(), isValid(), and The HSV Color Model.

source

pub unsafe fn to_q_variant(&self) -> CppBox<QVariant>

Returns the color as a QVariant

Calls C++ function: QVariant QColor::operator QVariant() const.

C++ documentation:

Returns the color as a QVariant

source

pub unsafe fn to_rgb(&self) -> CppBox<QColor>

Create and returns an RGB QColor based on this color.

Calls C++ function: QColor QColor::toRgb() const.

C++ documentation:

Create and returns an RGB QColor based on this color.

See also fromRgb(), convertTo(), and isValid().

source

pub unsafe fn value(&self) -> c_int

Returns the value color component of this color.

Calls C++ function: int QColor::value() const.

C++ documentation:

Returns the value color component of this color.

See also valueF(), getHsv(), and The HSV Color Model.

source

pub unsafe fn value_f(&self) -> c_double

Returns the value color component of this color.

Calls C++ function: double QColor::valueF() const.

C++ documentation:

Returns the value color component of this color.

See also value(), getHsvF(), and The HSV Color Model.

source

pub unsafe fn yellow(&self) -> c_int

Returns the yellow color component of this color.

Calls C++ function: int QColor::yellow() const.

C++ documentation:

Returns the yellow color component of this color.

See also yellowF(), getCmyk(), and The CMYK Color Model.

source

pub unsafe fn yellow_f(&self) -> c_double

Returns the yellow color component of this color.

Calls C++ function: double QColor::yellowF() const.

C++ documentation:

Returns the yellow color component of this color.

See also yellow(), getCmykF(), and The CMYK Color Model.

Trait Implementations§

source§

impl CppDeletable for QColor

source§

unsafe fn delete(&self)

The QColor class provides colors based on RGB, HSV or CMYK values.

Calls C++ function: [destructor] void QColor::~QColor().

C++ documentation:

The QColor class provides colors based on RGB, HSV or CMYK values.

A color is normally specified in terms of RGB (red, green, and blue) components, but it is also possible to specify it in terms of HSV (hue, saturation, and value) and CMYK (cyan, magenta, yellow and black) components. In addition a color can be specified using a color name. The color name can be any of the SVG 1.0 color names.

RGBHSVCMYK

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 setNamedColor() function. The color names are taken from the SVG 1.0 color names. The name() function returns the name of the color in the format "#RRGGBB". Colors can also be set using setRgb(), setHsv() and setCmyk(). To get a lighter or darker color use the lighter() and darker() functions respectively.

The isValid() function indicates whether a QColor is legal at all. For example, a RGB color with RGB values out of range is illegal. For performance reasons, QColor mostly disregards illegal colors, and for that reason, the result of using an invalid color is undefined.

The color components can be retrieved individually, e.g with red(), hue() and cyan(). The values of the color components can also be retrieved in one go using the getRgb(), getHsv() and getCmyk() functions. Using the RGB color model, the color components can in addition be accessed with rgb().

There are several related non-members: QRgb is a typdef for an unsigned int representing the RGB value triplet (r, g, b). Note that it also can hold a value for the alpha-channel (for more information, see the Alpha-Blended Drawing section). The qRed(), qBlue() and qGreen() functions return the respective component of the given QRgb value, while the qRgb() and qRgba() functions create and return the QRgb triplet based on the given component values. Finally, the qAlpha() function returns the alpha component of the provided QRgb, and the qGray() function calculates and return a gray value based on the given value.

QColor is platform and device independent. The QColormap class maps the color to the hardware.

For more information about painting in general, see the Paint System documentation.

source§

impl PartialEq<Ref<QColor>> for QColor

source§

fn eq(&self, c: &Ref<QColor>) -> bool

Returns true if this color has the same RGB and alpha values as color; otherwise returns false.

Calls C++ function: bool QColor::operator==(const QColor& c) const.

C++ documentation:

Returns true if this color has the same RGB and alpha values as color; otherwise returns false.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.