内容表

上一话题

QGLBuffer

下一话题

QGLContext

QGLColormap

QGLColormap class is used for installing custom colormaps into a QGLWidget . 更多

Inheritance diagram of PySide2.QtOpenGL.QGLColormap

概要

函数

详细描述

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.

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.

用法范例:

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)
											
class QGLColormap

QGLColormap(arg__1)

param arg__1

QGLColormap

构造 QGLColormap .

Construct a shallow copy of map .

PySide2.QtOpenGL.QGLColormap. entryColor ( idx )
参数

idx int

返回类型

QColor

返回 QRgb value in the colorcell with index idx .

PySide2.QtOpenGL.QGLColormap. entryRgb ( idx )
参数

idx int

返回类型

long

返回 QRgb value in the colorcell with index idx .

PySide2.QtOpenGL.QGLColormap. find ( color )
参数

color – long

返回类型

int

Returns the index of the color color 。若 color is not in the map, -1 is returned.

PySide2.QtOpenGL.QGLColormap. findNearest ( color )
参数

color – long

返回类型

int

Returns the index of the color that is the closest match to color color .

PySide2.QtOpenGL.QGLColormap. handle ( )
返回类型

Qt::HANDLE

PySide2.QtOpenGL.QGLColormap. isEmpty ( )
返回类型

bool

返回 true if the colormap is empty or it is not in use by a QGLWidget ;否则返回 false .

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.

比较 size() with zero to determine if the colormap is empty regardless of whether it is in use by a QGLWidget or not.

另请参阅

size()

PySide2.QtOpenGL.QGLColormap. setEntry ( idx , color )
参数
  • idx int

  • color QColor

PySide2.QtOpenGL.QGLColormap. setEntry ( idx , color )
参数
  • idx int

  • color – long

PySide2.QtOpenGL.QGLColormap. setHandle ( ahandle )
参数

ahandle Qt::HANDLE

PySide2.QtOpenGL.QGLColormap. size ( )
返回类型

int

Returns the number of colorcells in the colormap.