The QGLColormap class is used for installing custom colormaps into a QGLWidget . 更多...
QGLColormap provides a platform independent way of specifying and installing indexed colormaps for a QGLWidget . QGLColormap is especially useful when using the OpenGL color-index mode.
Under X11 you must use an X server that supports either a
PseudoColor
or
DirectColor
visual class. If your X server currently only provides a
GrayScale
,
TrueColor
,
StaticColor
or
StaticGray
visual, you will not be able to allocate colorcells for writing. If this is the case, try setting your X server to 8 bit mode. It should then provide you with at least a
PseudoColor
visual. Note that you may experience colormap flashing if your X server is running in 8 bit mode.
The size() of the colormap is always set to 256 colors. Note that under Windows you can also install colormaps in child widgets.
This class uses 隐式共享 as a memory and speed optimization.
用法范例:
#include <QApplication> #include <QGLColormap> int main(int argc, char *argv[]) { QApplication app(argc, argv); MySuperGLWidget widget; // a QGLWidget in color-index mode QGLColormap colormap; // This will fill the colormap with colors ranging from // black to white. const int size = 256; for (int i = 0; i < size; ++i) colormap.setEntry(i, qRgb(i, i, i)); widget.setColormap(colormap); widget.show(); return app.exec(); }
另请参阅 QGLWidget::setColormap () 和 QGLWidget::colormap ().