📄 qcolor.3qt
字号:
.TH QColor 3qt "6 July 1999" "Troll Tech AS" \" -*- nroff -*-.\" Copyright 1992-1999 Troll Tech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQColor \- Colors based on RGB.SH SYNOPSIS.br.PP\fC#include <qcolor.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "enum \fBSpec\fR { Rgb, Hsv }".br.ti -1c.BI "\fBQColor\fR ()".br.ti -1c.BI "\fBQColor\fR ( int " "r" ", int " "g" ", int b )".br.ti -1c.BI "\fBQColor\fR ( int " "x" ", int " "y" ", int " "z" ", Spec )".br.ti -1c.BI "\fBQColor\fR ( QRgb " "rgb" ", uint " "pixel" "=0xffffffff )".br.ti -1c.BI "\fBQColor\fR ( const QString & name )".br.ti -1c.BI "\fBQColor\fR ( const char * name )".br.ti -1c.BI "\fBQColor\fR ( const QColor & )".br.ti -1c.BI "QColor& \fBoperator=\fR ( const QColor & )".br.ti -1c.BI "bool \fBisValid\fR () const".br.ti -1c.BI "bool \fBisDirty\fR () const".br.ti -1c.BI "void \fBsetNamedColor\fR ( const QString & name )".br.ti -1c.BI "void \fBrgb\fR ( int * " "r" ", int * " "g" ", int * b ) const".br.ti -1c.BI "QRgb \fBrgb\fR () const".br.ti -1c.BI "void \fBsetRgb\fR ( int " "r" ", int " "g" ", int b )".br.ti -1c.BI "void \fBsetRgb\fR ( QRgb rgb )".br.ti -1c.BI "int \fBred\fR () const".br.ti -1c.BI "int \fBgreen\fR () const".br.ti -1c.BI "int \fBblue\fR () const".br.ti -1c.BI "void \fBhsv\fR ( int * " "h" ", int * " "s" ", int * v ) const".br.ti -1c.BI "void \fBgetHsv\fR ( int & " "h" ", int & " "s" ", int & v ) const".br.ti -1c.BI "void \fBsetHsv\fR ( int " "h" ", int " "s" ", int v )".br.ti -1c.BI "QColor \fBlight\fR ( int " "f" " = 150 ) const".br.ti -1c.BI "QColor \fBdark\fR ( int " "f" " = 200 ) const".br.ti -1c.BI "bool \fBoperator==\fR ( const QColor & c ) const".br.ti -1c.BI "bool \fBoperator!=\fR ( const QColor & c ) const".br.ti -1c.BI "uint \fBalloc\fR ()".br.ti -1c.BI "uint \fBpixel\fR () const".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "bool \fBlazyAlloc\fR ()".br.ti -1c.BI "void \fBsetLazyAlloc\fR ( bool )".br.ti -1c.BI "int \fBmaxColors\fR ()".br.ti -1c.BI "int \fBnumBitPlanes\fR ()".br.ti -1c.BI "int \fBenterAllocContext\fR ()".br.ti -1c.BI "void \fBleaveAllocContext\fR ()".br.ti -1c.BI "int \fBcurrentAllocContext\fR ()".br.ti -1c.BI "void \fBdestroyAllocContext\fR ( int )".br.ti -1c.BI "void \fBinitialize\fR ()".br.ti -1c.BI "void \fBcleanup\fR ()".br.in -1c.SH RELATED FUNCTION DOCUMENTATION(Note that these are not member functions.).in +1c.ti -1c.BI "int \fBqBlue\fR (QRgb " "rgb" ")".br.ti -1c.BI "QRgb \fBqRgb\fR (int " "r" ", int " "g" ", int " "b" ")".br.ti -1c.BI "QDataStream & \fBoperator<<\fR (QDataStream & " "s" ", const QColor & " "c" ")".br.ti -1c.BI "QDataStream & \fBoperator>>\fR (QDataStream & " "s" ", QColor & " "c" ")".br.ti -1c.BI "int \fBqGreen\fR (QRgb " "rgb" ")".br.ti -1c.BI "int \fBqGray\fR (int " "r" ", int " "g" ", int " "b" ")".br.ti -1c.BI "int \fBqRed\fR (QRgb " "rgb" ")".br.ti -1c.BI "int \fBqGray\fR (qRgb " "rgb" ")".br.in -1c.SH DESCRIPTIONThe QColor class provides colors based on RGB..PPA color is normally specified in terms of RGB (red,green and blue) components, but it is also possible to specify HSV (hue,saturation and value) or set a color name (the names are copied from from the X11 color database)..PPIn addition to the RGB value, a QColor also has a pixel value. This value is used by the underlying window system to refer to a color. It can be thought of as an index into the display hardware's color table..PPThere are 19 predefined QColor objects: \fCblack, white, darkGray, gray, lightGray, red, green, blue, cyan, magenta, yellow, darkRed, darkGreen, darkBlue, darkCyan, darkMagenta, darkYellow, color0\fR and \fCcolor1.\fR.PPThe colors \fCcolor0\fR (zero pixel value) and \fCcolor1\fR (non-zero pixel value) are special colors for drawing in bitmaps..PPThe QColor class has an efficient, dynamic color allocation strategy. A color is normally allocated the first time it is used (lazy allocation), that is, whenever the pixel() function is called:.IP 1Is the pixel value valid? If it is, just return it, otherwise, allocate a pixel value..IP 2Check an internal hash table to see if we allocated an equal RGB value earlier. If we did, set the pixel value and return..IP 3Try to allocate the RGB value. If we succeed, we get a pixel value which we save in the internal table with the RGB value. Return the pixel value..IP 4The color could not be allocated. Find the closest matching color and save it in the internal table..PPSince many people don't know the HSV color model very well, we'll cover it briefly here..PPThe 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 traditional human perception of color. For example, the relationships "stronger than", "darker than", "the opposite of" are easily expressed in HSV, but are much harder to express in RGB..PPHSV, like RGB, has three components. They are: .TPH, for hue, is either 0-360 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. .TPS, for saturation, is 0-255 and the bigger it is, the stronger the color is. Grayish colors have saturation near 0, very strong colors have saturation near 255. .TPV, for value, is 0-255 and represents lightness or brightness of the color. 0 is black, 255 is far from black as possible. .PPHere are some examples: Pure red is H=0, S=255, V=255. A dark red, moving slightly towards the magenta, could be H=350 (equvalent 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..PPSee also: QPalette, QColorGroup, QApplication::setColorSpec() and Color FAQ..PPExamples:.(lgrapher/grapher.cpp drawlines/connect.cpp drawdemo/drawdemo.cpp progress/progress.cpp desktop/desktop.cpp picture/picture.cpp.)l.SH MEMBER FUNCTION DOCUMENTATION.SH "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..PPSee also: isValid()..SH "QColor::QColor ( QRgb rgb, uint pixel=0xffffffff )"Constructs a color with a RGB value and a custom pixel value..PPIf the \fIpixel\fR = 0xffffffff, then the color uses the RGB value in a standard way. If \fIpixel\fR is something else, then the pixel value will be set directly to \fIpixel\fR (skips the normal allocation procedure)..SH "QColor::QColor ( const QString & name )"Constructs a named color in the same way as setNamedColor()..PPSee also: setNamedColor()..SH "QColor::QColor ( const QColor & c )"Constructs a color that is a copy of \fIc.\fR.SH "QColor::QColor ( const char * name )"Constructs a named color in the same way as setNamedColor()..PPSee also: setNamedColor()..SH "QColor::QColor ( int r, int g, int b )"Constructs a color with the RGB value \fI(r,g,b). r, g\fR and \fIb\fR must be in the range 0..255..PPSee also: setRgb()..SH "QColor::QColor ( int x, int y, int z, Spec colorSpec )"Constructs a color with the RGB \fIor\fR HSV value \fI(x,y,z).\fR.PPThe \fI(x,y,z)\fR triplet defines an RGB value if \fIcolorSpec\fR == \fCQColor::Rgb.\fR \fIx\fR (red), \fIy\fR (green) and \fIz\fR (blue) must be in the range 0..255..PPThe \fI(x,y,z)\fR triplet defines a HSV value if \fIcolorSpec\fR == \fCQColor::Hsv.\fR \fIx\fR (hue) must be in the range -1..360 (-1 means achromatic), and \fIy\fR (saturation) and \fIz\fR (value) must be in the range 0..255..PPSee also: setRgb() and setHsv()..SH "uint QColor::alloc ()"Allocates the RGB color and returns the pixel value..PPAllocating a color means to obtain a pixel value from the RGB specification. The pixel value is an index into the global color table, but should be considered an arbitrary platform-dependent value..PPThe pixel() function calls alloc() if necessary, so in general you don't need to call this function..PPSee also: setLazyAlloc() and enterAllocContext()..SH "int QColor::blue () const"Returns the B (blue) component of the RGB value..SH "void QColor::cleanup () \fC[static]\fR"Internal clean up required for QColor. This function is called from the QApplication destructor..PPSee also: initialize()..SH "int QColor::currentAllocContext () \fC[static]\fR"Returns the current color allocation context..PPThe default context is 0..PPSee also: enterAllocContext() and leaveAllocContext()..SH "QColor QColor::dark ( int factor = 200 ) const"Returns a darker (or lighter) color..PPReturns a darker color if \fIfactor\fR is greater than 100. Setting \fIfactor\fR to 300 returns a color that has one third the brightness..PPReturns a lighter color if \fIfactor\fR is less than 100, equal to light(10000 / \fIfactor).\fR.PPThis function converts the current RGB color to HSV, divides V by \fIfactor\fR and converts back to RGB..PPSee also: light()..PPExamples:.(ldesktop/desktop.cpp.)l.SH "void QColor::destroyAllocContext ( int context ) \fC[static]\fR"Destroys a color allocation context, \fIcontext.\fR.PPThis function deallocates all colors that were allocated in the specified \fIcontext.\fR If \fIcontext\fR == -1, it frees up all colors that the application has allocated. If \fIcontext\fR == -2, it frees up all colors that the application has allocated, except those in the default context.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -