QGLColormap¶
The
QGLColormap
class is used for installing custom colormaps into aQGLWidget
. More…
Synopsis¶
Functions¶
def
entryColor
(idx)def
entryRgb
(idx)def
find
(color)def
findNearest
(color)def
handle
()def
isEmpty
()def
setEntry
(idx, color)def
setEntry
(idx, color)def
setHandle
(ahandle)def
size
()
Detailed Description¶
QGLColormap
provides a platform independent way of specifying and installing indexed colormaps for aQGLWidget
.QGLColormap
is especially useful when using the OpenGL color-index mode.Under X11 you must use an X server that supports either a
PseudoColor
orDirectColor
visual class. If your X server currently only provides aGrayScale
,TrueColor
,StaticColor
orStaticGray
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 aPseudoColor
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 implicit sharing as a memory and speed optimization.
Example of use:
import sys from PySide2.QtGui import QApplication, qRgb from PySide2.QtOpenGL import QGLColormap def main(argv): app = QApplication(argv) widget = MySuperGLWidget() # a QGLWidget in color-index mode colormap = QGLColormap() # This will fill the colormap with colors ranging from # black to white. for i in range(0, colormap.size()): colormap.setEntry(i, qRgb(i, i, i)) widget.setColormap(colormap) widget.show() return app.exec_() if __name__ == "__main__": main(sys.argv)See also
- class PySide2.QtOpenGL.QGLColormap¶
PySide2.QtOpenGL.QGLColormap(arg__1)
- param arg__1:
Construct a
QGLColormap
.Construct a shallow copy of
map
.
- PySide2.QtOpenGL.QGLColormap.entryColor(idx)¶
- Parameters:
idx – int
- Return type:
Returns the
QRgb
value in the colorcell with indexidx
.
- PySide2.QtOpenGL.QGLColormap.entryRgb(idx)¶
- Parameters:
idx – int
- Return type:
int
Returns the
QRgb
value in the colorcell with indexidx
.
- PySide2.QtOpenGL.QGLColormap.find(color)¶
- Parameters:
color – int
- Return type:
int
Returns the index of the color
color
. Ifcolor
is not in the map, -1 is returned.
- PySide2.QtOpenGL.QGLColormap.findNearest(color)¶
- Parameters:
color – int
- Return type:
int
Returns the index of the color that is the closest match to color
color
.
- PySide2.QtOpenGL.QGLColormap.handle()¶
- Return type:
Qt::HANDLE
- PySide2.QtOpenGL.QGLColormap.isEmpty()¶
- Return type:
bool
Returns
true
if the colormap is empty or it is not in use by aQGLWidget
; otherwise returnsfalse
.A colormap with no color values set is considered to be empty. For historical reasons, a colormap that has color values set but which is not in use by a
QGLWidget
is also considered empty.Compare
size()
with zero to determine if the colormap is empty regardless of whether it is in use by aQGLWidget
or not.See also
- PySide2.QtOpenGL.QGLColormap.setEntry(idx, color)¶
- Parameters:
idx – int
color –
PySide2.QtGui.QColor
- PySide2.QtOpenGL.QGLColormap.setEntry(idx, color)
- Parameters:
idx – int
color – int
- PySide2.QtOpenGL.QGLColormap.setHandle(ahandle)¶
- Parameters:
ahandle –
Qt::HANDLE
- PySide2.QtOpenGL.QGLColormap.size()¶
- Return type:
int
Returns the number of colorcells in the colormap.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.