Qt:Документация 4.3.2/qcolor

Материал из Wiki.crossplatform.ru

Версия от 09:03, 14 ноября 2008; Root (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QColor Class Reference
[модуль QtGui ]

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

 #include <QColor>

[править] Открытые типы

  • enum Spec { Rgb, Hsv, Cmyk, Invalid }

[править] Открытые функции

[править] Статические открытые члены

[править] Связанные не-члены

  • typedef QRgb
  • int qAlpha ( QRgb rgba )
  • int qBlue ( QRgb rgb )
  • int qGray ( int r, int g, int b )
  • int qGray ( QRgb rgb )
  • int qGreen ( QRgb rgb )
  • int qRed ( QRgb rgb )
  • QRgb qRgb ( int r, int g, int b )
  • QRgb qRgba ( int r, int g, int b, int a )
  • QDataStream & operator<< ( QDataStream & stream, const QColor & color )
  • QDataStream & operator>> ( QDataStream & stream, QColor & color )

[править] Подробное описание

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.


center center center
RGB HSV CMYK

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

[править] Integer vs. Floating Point Precision

QColor supports floating point precision and provides floating point versions of all the color components functions, e.g. getRgbF(), hueF() and fromCmykF(). Note that since the components are stored using 16-bit integers, there might be minor deviations between the values set using, for example, setRgbF() and the values returned by the getRgbF() function due to rounding.

While the integer based functions take values in the range 0-255 (except hue() which must have values within the range 0-359), the floating point functions accept values in the range 0.0 - 1.0.

[править] Alpha-Blended Drawing

QColor also support alpha-blended outlining and filling. The alpha channel of a color specifies the transparency effect, 0 represents a fully transparent color, while 255 represents a fully opaque color. For example:

 // Specfiy semi-transparent red
 painter.setBrush(QColor(255, 0, 0, 127));
 painter.drawRect(0, 0, width()/2, height());
 
 // Specify semi-transparend blue
 painter.setBrush(QColor(0, 0, 255, 127));
 painter.drawRect(0, 0, width(), height()/2);

The code above produces the following output:

center

Alpha-blended drawing is supported on Windows, Mac OS X, and on X11 systems that have the X Render extension installed.

The alpha channel of a color can be retrieved and set using the alpha() and setAlpha() functions if its value is an integer, and alphaF() and setAlphaF() if its value is qreal (double). By default, the alpha-channel is set to 255 (opaque). To retrieve and set all the RGB color components (including the alpha-channel) in one go, use the rgba() and setRgba() functions.

[править] Predefined Colors

There are 20 predefined QColors: Qt::white, Qt::black, Qt::red, Qt::darkRed, Qt::green, Qt::darkGreen, Qt::blue, Qt::darkBlue, Qt::cyan, Qt::darkCyan, Qt::magenta, Qt::darkMagenta, Qt::yellow, Qt::darkYellow, Qt::gray, Qt::darkGray, Qt::lightGray, Qt::color0, Qt::color1, and Qt::transparent.

center

QColor provides the static colorNames() function which returns a QStringList containing the color names Qt knows about.

The colors Qt::color0 (zero pixel value) and Qt::color1 (non-zero pixel value) are special colors for drawing in QBitmaps. Painting with Qt::color0 sets the bitmap bits to 0 (transparent, i.e. background), and painting with Qt::color1 sets the bits to 1 (opaque, i.e. foreground).

[править] The HSV Color Model

The RGB model is hardware-oriented. Its representation is close to what most monitors show. In contrast, HSV represents color in a way more suited to the human perception of color. For example, the relationships "stronger than", "darker than", and "the opposite of" are easily expressed in HSV but are much harder to express in RGB.

HSV, like RGB, has three components:

  • H, for hue, is in the range 0 to 359 if the color is chromatic (not gray), or meaningless if it is gray. It represents degrees on the color wheel familiar to most people. Red is 0 (degrees), green is 120, and blue is 240.
    center
  • S, for saturation, is in the range 0 to 255, and the bigger it is, the stronger the color is. Grayish colors have saturation near 0; very strong colors have saturation near 255.
    center
  • V, for value, is in the range 0 to 255 and represents lightness or brightness of the color. 0 is black; 255 is as far from black as possible.
    center

Here are some examples: pure red is H=0, S=255, V=255; a dark red, moving slightly towards the magenta, could be H=350 (equivalent to -10), S=255, V=180; a grayish light red could have H about 0 (say 350-359 or 0-10), S about 50-100, and S=255.

Qt returns a hue value of -1 for achromatic colors. If you pass a hue value that is too large, Qt forces it into range. Hue 360 or 720 is treated as 0; hue 540 is treated as 180.

In addition to the standard HSV model, Qt provides an alpha-channel to feature alpha-blended drawing.

[править] The CMYK Color Model

While the RGB and HSV color models are used for display on computer monitors, the CMYK model is used in the four-color printing process of printing presses and some hard-copy devices.

CMYK has four components, all in the range 0-255: cyan (C), magenta (M), yellow (Y) and black (K). Cyan, magenta and yellow are called subtractive colors; the CMYK color model creates color by starting with a white surface and then subtracting color by applying the appropriate components. While combining cyan, magenta and yellow gives the color black, subtracting one or more will yield any other color. When combined in various percentages, these three colors can create the entire spectrum of colors.

Mixing 100 percent of cyan, magenta and yellow does produce black, but the result is unsatisfactory since it wastes ink, increases drying time, and gives a muddy colour when printing. For that reason, black is added in professional printing to provide a solid black tone; hence the term 'four color process'.

In addition to the standard CMYK model, Qt provides an alpha-channel to feature alpha-blended drawing.

See also QPalette, QBrush, and QApplication::setColorSpec().


[править] Описание типов членов

[править]
enum QColor::Spec

The type of color specified, either RGB, HSV or CMYK.


Constant Value
QColor::Rgb 1
QColor::Hsv 2
QColor::Cmyk 3
QColor::Invalid 0

See also spec() and convertTo().


[править] Описание функций-членов

[править]
QColor::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.

The alpha value of an invalid color is unspecified.

See also isValid().

[править]
QColor::QColor ( int r, int g, int b, int a = 255 )

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

[править]
QColor::QColor ( QRgb color )

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

See also fromRgb() and isValid().

[править]
QColor::QColor ( const QString & name )

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

[править]
QColor::QColor ( const char * name )

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

[править]
QColor::QColor ( const QColor & color )

Constructs a color that is a copy of color.

See also isValid().

[править]
QColor::QColor ( Qt::GlobalColor color )

Constructs a new color with a color value of color.

See also isValid() and Predefined Colors.

[править]
bool QColor::allowX11ColorNames () [static]

Returns true if setNamedColor() is allowed to look up colors in the X11 color database. By default, this function returns false.

See also setAllowX11ColorNames().

[править]
int QColor::alpha () const

Returns the alpha color component of this color.

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

[править]
qreal QColor::alphaF () const

Returns the alpha color component of this color.

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

[править]
int QColor::black () const

Returns the black color component of this color.

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

[править]
qreal QColor::blackF () const

Returns the black color component of this color.

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

[править]
int QColor::blue () const

Returns the blue color component of this color.

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

[править]
qreal QColor::blueF () const

Returns the blue color component of this color.

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

[править]
QStringList QColor::colorNames () [static]

Returns a QStringList containing the color names Qt knows about.

See also Predefined Colors.

[править]
QColor QColor::convertTo ( Spec colorSpec ) const

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

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

[править]
int QColor::cyan () const

Returns the cyan color component of this color.

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

[править]
qreal QColor::cyanF () const

Returns the cyan color component of this color.

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

[править]
QColor QColor::darker ( int factor = 200 ) const

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

[править]
QColor QColor::fromCmyk ( int c, int m, int y, int k, int a = 255 ) [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.

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

[править]
QColor QColor::fromCmykF ( qreal c, qreal m, qreal y, qreal k, qreal a = 1.0 ) [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.0-1.0.

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

[править]
QColor QColor::fromHsv ( int h, int s, int v, int a = 255 ) [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.

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

[править]
QColor QColor::fromHsvF ( qreal h, qreal s, qreal v, qreal a = 1.0 ) [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).

All the values must be in the range 0.0-1.0.

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

[править]
QColor QColor::fromRgb ( QRgb rgb ) [static]

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

Note that the alpha component of rgb is ignored (i.e. it is automatically set to 255), use the fromRgba() function to include the alpha-channel specified by the given QRgb value.

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

[править]
QColor QColor::fromRgb ( int r, int g, int b, int a = 255 ) [static]

This is an overloaded member function, provided for convenience.

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(), fromRgbF(), and isValid().

[править]
QColor QColor::fromRgbF ( qreal r, qreal g, qreal b, qreal a = 1.0 ) [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.0-1.0.

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

[править]
QColor QColor::fromRgba ( QRgb rgba ) [static]

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

Note that unlike the fromRgb() function, the alpha-channel specified by the given QRgb value is included.

See also fromRgb() and isValid().

[править]
void QColor::getCmyk ( int * c, int * m, int * y, int * k, int * a = 0 )

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.

Note that the components can be retrieved individually using the cyan(), magenta(), yellow(), black() and alpha() functions.

See also setCmyk() and The CMYK Color Model.

[править]
void QColor::getCmykF ( qreal * c, qreal * m, qreal * y, qreal * k, qreal * a = 0 )

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.

Note that the components can be retrieved individually using the cyanF(), magentaF(), yellowF(), blackF() and alphaF() functions.

See also setCmykF() and The CMYK Color Model.

[править]
void QColor::getHsv ( int * h, int * s, int * v, int * a = 0 ) 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.

Note that the components can be retrieved individually using the hue(), saturation(), value() and alpha() functions.

See also setHsv() and The HSV Color Model.

[править]
void QColor::getHsvF ( qreal * h, qreal * s, qreal * v, qreal * a = 0 ) 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.

Note that the components can be retrieved individually using the hueF(), saturationF(), valueF() and alphaF() functions.

See also setHsv() and The HSV Color Model.

[править]
void QColor::getRgb ( int * r, int * g, int * b, int * a = 0 ) 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.

Note that the components can be retrieved individually using the red(), green(), blue() and alpha() functions.

See also rgb() and setRgb().

[править]
void QColor::getRgbF ( qreal * r, qreal * g, qreal * b, qreal * a = 0 ) 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.

Note that the components can be retrieved individually using the redF(), greenF(), blueF() and alphaF() functions.

See also rgb() and setRgb().

[править]
int QColor::green () const

Returns the green color component of this color.

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

[править]
qreal QColor::greenF () const

Returns the green color component of this color.

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

[править]
int QColor::hue () const

Returns the hue color component of this color.

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

[править]
qreal QColor::hueF () const

Returns the hue color component of this color.

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

[править]
bool QColor::isValid () const

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

[править]
QColor QColor::lighter ( int factor = 150 ) const

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

[править]
int QColor::magenta () const

Returns the magenta color component of this color.

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

[править]
qreal QColor::magentaF () const

Returns the magenta color component of this color.

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

[править]
QString QColor::name () const

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

See also setNamedColor().

[править]
int QColor::red () const

Returns the red color component of this color.

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

[править]
qreal QColor::redF () const

Returns the red color component of this color.

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

[править]
QRgb QColor::rgb () const

Returns the RGB value of the color. The alpha is stripped for compatibility.

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

[править]
QRgb QColor::rgba () const

Returns the RGB value of the color. Note that unlike rgb(), the alpha is not stripped.

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

See also setRgba() and rgb().

[править]
int QColor::saturation () const

Returns the saturation color component of this color.

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

[править]
qreal QColor::saturationF () const

Returns the saturation color component of this color.

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

[править]
void QColor::setAllowX11ColorNames ( bool enabled ) [static]

Allow setNamedColor() to look up colors in the X11 color database if enabled. By default, setNamedColor() does not look up colors in the X11 color database.

See also setNamedColor() and allowX11ColorNames().

[править]
void QColor::setAlpha ( int alpha )

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.

[править]
void QColor::setAlphaF ( qreal alpha )

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.

[править]
void QColor::setBlue ( int blue )

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

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

[править]
void QColor::setBlueF ( qreal blue )

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

[править]
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.

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

[править]
void QColor::setCmykF ( qreal c, qreal m, qreal y, qreal k, qreal a = 1.0 )

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.

[править]
void QColor::setGreen ( int green )

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

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

[править]
void QColor::setGreenF ( qreal green )

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

[править]
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.

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

[править]
void QColor::setHsvF ( qreal h, qreal s, qreal v, qreal 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.

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

[править]
void QColor::setNamedColor ( const QString & name )

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

    1. RGB (each of R, G, and B is a single hex digit)
    2. RRGGBB
    3. RRRGGGBBB
    4. 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.
  • transparent - representing the absence of a color.
  • X11 only: If allowX11ColorNames() returns true, any valid X11 color name. See the documentation for XParseColor() for information about valid X11 color names.

The color is invalid if name cannot be parsed.

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

[править]
void QColor::setRed ( int red )

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

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

[править]
void QColor::setRedF ( qreal red )

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

[править]
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.

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

[править]
void QColor::setRgb ( QRgb rgb )

This is an overloaded member function, provided for convenience.

Sets the RGB value to rgb, ignoring the alpha.

[править]
void QColor::setRgbF ( qreal r, qreal g, qreal b, qreal a = 1.0 )

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

[править]
void QColor::setRgba ( QRgb rgba )

Sets the RGBA value to rgba. Note that unlike setRgb( QRgb rgb), this function does not ignore the alpha.

See also rgba() and rgb().

[править]
Spec QColor::spec () const

Returns how the color was specified.

See also Spec and convertTo().

[править]
QColor QColor::toCmyk () const

Creates and returns a CMYK QColor based on this color.

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

[править]
QColor QColor::toHsv () const

Creates and returns an HSV QColor based on this color.

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

[править]
QColor QColor::toRgb () const

Create and returns an RGB QColor based on this color.

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

[править]
int QColor::value () const

Returns the value color component of this color.

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

[править]
qreal QColor::valueF () const

Returns the value color component of this color.

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

[править]
int QColor::yellow () const

Returns the yellow color component of this color.

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

[править]
qreal QColor::yellowF () const

Returns the yellow color component of this color.

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

[править]
QColor::operator QVariant () const

Returns the color as a QVariant

[править]
bool QColor::operator!= ( const QColor & color ) const

Returns true if this color has a different RGB value from the color color; otherwise returns false.

[править]
QColor & QColor::operator= ( const QColor & color )

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

[править]
QColor & QColor::operator= ( Qt::GlobalColor color )

This is an overloaded member function, provided for convenience.

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

[править]
bool QColor::operator== ( const QColor & color ) const

Returns true if this color has the same RGB value as the color color; otherwise returns false.


[править] Связанные не-члены

[править]
typedef QRgb

An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.

Note that the type also holds a value for the alpha-channel. The default alpha channel is ff, i.e opaque. For more information, see the Alpha-Blended Drawing section.

See also QColor::rgb() and QColor::rgba().

[править]
int qAlpha ( QRgb rgba )

Returns the alpha component of the ARGB quadruplet rgba.

See also qRgb() and QColor::alpha().

[править]
int qBlue ( QRgb rgb )

Returns the blue component of the ARGB quadruplet rgb.

See also qRgb() and QColor::blue().

[править]
int qGray ( int r, int g, int b )

Returns a gray value (0 to 255) from the (r, g, b) triplet.

The gray value is calculated using the formula (r * 11 + g * 16 + b * 5)/32.

[править]
int qGray ( QRgb rgb )

This is an overloaded member function, provided for convenience.

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. Note that the alpha-channel is ignored.

[править]
int qGreen ( QRgb rgb )

Returns the green component of the ARGB quadruplet rgb.

See also qRgb() and QColor::green().

[править]
int qRed ( QRgb rgb )

Returns the red component of the ARGB quadruplet rgb.

See also qRgb() and QColor::red().

[править]
QRgb qRgb ( int r, int g, int b )

Returns the ARGB quadruplet (255, r, g, b).

See also qRgba(), qRed(), qGreen(), and qBlue().

[править]
QRgb qRgba ( int r, int g, int b, int a )

Returns the ARGB quadruplet (a, r, g, b).

See also qRgb(), qRed(), qGreen(), and qBlue().

[править]
QDataStream & operator<< ( QDataStream & stream, const QColor & color )

This is an overloaded member function, provided for convenience.

Writes the color to the stream.

See also Format of the QDataStream Operators.

[править]
QDataStream & operator>> ( QDataStream & stream, QColor & color )

This is an overloaded member function, provided for convenience.

Reads the color from the stream.

See also Format of the QDataStream Operators.


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2