📄 qcolor.3qt
字号:
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..PPThe function does nothing for true color displays..PPSee also enterAllocContext() and alloc()..SH "int QColor::enterAllocContext () \fC[static]\fR"Enters a color allocation context and returns a nonzero unique identifier..PPColor allocation contexts are useful for programs that need to allocate many colors and throw them away later, like image viewers. The allocation context functions work for true color displays as well as colormap display, except that QColor::destroyAllocContext() does nothing for true color..PPExample:.PP.nf.br QPixmap loadPixmap( QString fileName ).br {.br static int alloc_context = 0;.br if ( alloc_context ).br QColor::destroyAllocContext( alloc_context );.br alloc_context = QColor::enterAllocContext();.br QPixmap pm( fileName );.br QColor::leaveAllocContext();.br return pm;.br }.fi.PPThe example code loads a pixmap from file. It frees up all colors that were allocated the last time loadPixmap() was called..PPThe initial/default context is 0. Qt keeps a list of colors associated with their allocation contexts. You can call destroyAllocContext() to get rid of all colors that were allocated in a specific context..PPCalling enterAllocContext() enters an allocation context. The allocation context lasts until you call leaveAllocContext(). QColor has an internal stack of allocation contexts. Each call to enterAllocContex() must have a corresponding leaveAllocContext()..PP.nf.br // context 0 active.br int c1 = QColor::enterAllocContext(); // enter context c1.br // context c1 active.br int c2 = QColor::enterAllocContext(); // enter context c2.br // context c2 active.br QColor::leaveAllocContext(); // leave context c2.br // context c1 active.br QColor::leaveAllocContext(); // leave context c1.br // context 0 active.br // Now, free all colors that were allocated in context c2.br QColor::destroyAllocContext( c2 );.fi.PPYou may also want to set the application's color specification. See QApplication::setColorSpec() for more information..PPSee also leaveAllocContext(), currentAllocContext(), destroyAllocContext() and QApplication::setColorSpec()..SH "void QColor::getHsv ( int & h, int & s, int & v ) const"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..SH "int QColor::green () const"Returns the G (green) component of the RGB value..SH "void QColor::hsv ( int * h, int * s, int * v ) const"Returns the current RGB value as HSV..PPArguments:.TP\fI*h,\fR hue..TP\fI*s,\fR saturation..TP\fI*v,\fR value. The hue defines the color. Its range is 0..359 if the color is chromatic and -1 if the color is achromatic. The saturation and value both vary between 0 and 255 inclusive..PPSee also setHsv() and rgb()..SH "void QColor::initialize () \fC[static]\fR"Internal initialization required for QColor. This function is called from the QApplication constructor..PPSee also cleanup()..SH "bool QColor::isDirty () const"Returns TRUE if the color is dirty, i.e. lazy allocation is enabled and an RGB/HSV value has been set but not allocated..PPSee also setLazyAlloc(), alloc() and pixel()..SH "bool QColor::isValid () const"Returns FALSE if the color is invalid, i.e. it was constructed using the default constructor..SH "bool QColor::lazyAlloc () \fC[static]\fR"Returns TRUE if lazy color allocation is enabled (on-demand allocation), or FALSE if it is disabled (immediate allocation)..PPSee also setLazyAlloc()..SH "void QColor::leaveAllocContext () \fC[static]\fR"Leaves a color allocation context..PPSee enterAllocContext() for a detailed explanation..PPSee also enterAllocContext() and currentAllocContext()..SH "QColor QColor::light ( int factor = 150 ) const"Returns a lighter (or darker) color..PPReturns a lighter color if \fIfactor\fR is greater than 100. Setting \fIfactor\fR to 150 returns a color that is 50% brighter..PPReturns a darker color if \fIfactor\fR is less than 100, equal to dark(10000 / \fIfactor).\fR.PPThis function converts the current RGB color to HSV, multiplies V with \fIfactor\fR and converts back to RGB..PPSee also dark()..PPExamples:.(ldesktop/desktop.cpp.)l.SH "int QColor::maxColors () \fC[static]\fR"Returns the maximum number of colors supported by the underlying window system..SH "QString QColor::name () const"Returns the name of the color in the format #RRGGBB..PPSee also setNamedColor()..SH "int QColor::numBitPlanes () \fC[static]\fR"Returns the number of color bit planes for the underlying window system..PPThe returned values is equal to the default pixmap depth;.PPSee also QPixmap::defaultDepth()..SH "bool QColor::operator!= ( const QColor & c ) const"Returns TRUE if this color has different RGB value from \fIc,\fR or FALSE if they have equal RGB values..SH "QColor & QColor::operator= ( const QColor & c )"Assigns a copy of the color \fCand\fR returns a reference to this color..SH "bool QColor::operator== ( const QColor & c ) const"Returns TRUE if this color has the same RGB value as \fIc,\fR or FALSE if they have different RGB values..SH "uint QColor::pixel () const"Returns the pixel value..PPThis 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, but the value is an arbitrary 32-bit value..PPSee also setLazyAlloc() and alloc()..SH "int QColor::red () const"Returns the R (red) component of the RGB value..SH "QRgb QColor::rgb () const"Returns the RGB value..PPThe return type \fIQRgb\fR is equivalent to \fCunsigned int.\fR.PPSee also setRgb(), hsv(), qRed(), qBlue() and qGreen()..SH "void QColor::rgb ( int * r, int * g, int * b ) const"Returns the red, green and blue components of the RGB value in \fI*r, *g\fR and \fI*b.\fR The value range for a component is 0..255..PPSee also setRgb() and hsv()..SH "void QColor::setHsv ( int h, int s, int v )"Sets a HSV color value..PPArguments:.TP\fIh,\fR hue (-1,0..360). -1 means achromatic..TP\fIs,\fR saturation (0..255)..TP\fIv,\fR value (0..255)..PPSee also hsv() and setRgb()..PPExamples:.(lgrapher/grapher.cpp drawdemo/drawdemo.cpp progress/progress.cpp.)l.SH "void QColor::setLazyAlloc ( bool enable ) \fC[static]\fR"Enables or disables lazy color allocation..PPIf lazy allocation is enabled, colors are allocated the first time they are used (upon calling the pixel() function). If lazy allocation is disabled, colors are allocated when they are constructed or when either setRgb() or setHsv() is called..PPLazy color allocation is enabled by default..PPSee also lazyAlloc(), pixel() and alloc()..SH "void QColor::setNamedColor ( const QString & name )"Sets the RGB value to that of the named color..PPThe color name may be in one of five formats: .TP#RGB (each of R, G and B is a single hex digit).TP#RRGGBB.TP#RRRGGGBBB.TP#RRRRGGGGBBBB.TPA named from the X color database (rgb.txt), e.g. "steelblue" or "gainsboro". These color names also work under Qt for Windows..SH "void QColor::setRgb ( QRgb rgb )"Sets the RGB value to \fIrgb.\fR.PPThe type \fIQRgb\fR is equivalent to \fCunsigned int.\fR.PPSee also rgb() and setHsv()..SH "void QColor::setRgb ( int r, int g, int b )"Sets the RGB value to \fI(r,g,b). r, g\fR and \fIb\fR must be in the range 0..255..PPSee also rgb() and setHsv()..SH RELATED FUNCTION DOCUMENTATION.SH "int qBlue (QRgb rgb)"Returns the blue component of the RGB triplet \fIrgb.\fR.PPSee also qRgb() and QColor::blue()..PPExamples:.(lqmag/qmag.cpp.)l.SH "QRgb qRgb (int r, int g, int b)"Returns the RGB triplet \fI(r,g,b).\fR.PPThe return type \fIQRgb\fR is equivalent to \fCunsigned int.\fR.PPSee also qRgba(), qRed(), qGreen() and qBlue()..PPExamples:.(ldesktop/desktop.cpp.)l.SH "QRgb qRgba (int r, int g, int b, int a)"Returns the RGBA triplet \fI(r,g,b,a).\fR.PPThe return type \fIQRgb\fR is equivalent to \fCunsigned int.\fR.PPSee also qRgb(), qRed(), qGreen() and qBlue()..SH "QDataStream & operator<< (QDataStream & s, const QColor & c)"Writes a color object to the stream..PPSee also Format of the QDataStream operators.SH "QDataStream & operator>> (QDataStream & s, QColor & c)"Reads a color object from the stream..PPSee also Format of the QDataStream operators.SH "int qGreen (QRgb rgb)"Returns the green component of the RGB triplet \fIrgb.\fR.PPSee also qRgb() and QColor::green()..PPExamples:.(lqmag/qmag.cpp.)l.SH "int qGray (int r, int g, int b)"Returns a gray value 0..255 from the \fI(r,g,b)\fR triplet..PPThe gray value is calculated using the formula: \fC(r*11 + g*16 + b*5)/32\fR.SH "int qRed (QRgb rgb)"Returns the red component of the RGB triplet \fIrgb.\fR.PPSee also qRgb() and QColor::red()..PPExamples:.(lqmag/qmag.cpp.)l.SH "int qGray (qRgb rgb)"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "SEE ALSO".BR http://doc.trolltech.com/qcolor.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -