<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qglcolormap.cpp --> <title>Qt 4.8: QGLColormap Class Reference</title> <link rel="stylesheet" type="text/css" href="style/style.css" /> <script src="scripts/jquery.js" type="text/javascript"></script> <script src="scripts/functions.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="style/superfish.css" /> <link rel="stylesheet" type="text/css" href="style/narrow.css" /> <!--[if IE]> <meta name="MSSmartTagsPreventParsing" content="true"> <meta http-equiv="imagetoolbar" content="no"> <![endif]--> <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie6.css"> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie7.css"> <![endif]--> <!--[if IE 8]> <link rel="stylesheet" type="text/css" href="style/style_ie8.css"> <![endif]--> <script src="scripts/superfish.js" type="text/javascript"></script> <script src="scripts/narrow.js" type="text/javascript"></script> </head> <body class="" onload="CheckEmptyAndLoadList();"> <div class="header" id="qtdocheader"> <div class="content"> <div id="nav-logo"> <a href="index.html">Home</a></div> <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a> <div id="narrowsearch"></div> <div id="nav-topright"> <ul> <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li> <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li> <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/"> DOC</a></li> <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li> </ul> </div> <div id="shortCut"> <ul> <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li> <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS </a></li> </ul> </div> <ul class="sf-menu" id="narrowmenu"> <li><a href="#">API Lookup</a> <ul> <li><a href="classes.html">Class index</a></li> <li><a href="functions.html">Function index</a></li> <li><a href="modules.html">Modules</a></li> <li><a href="namespaces.html">Namespaces</a></li> <li><a href="qtglobal.html">Global Declarations</a></li> <li><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </li> <li><a href="#">Qt Topics</a> <ul> <li><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li><a href="supported-platforms.html">Supported Platforms</a></li> <li><a href="technology-apis.html">Qt and Key Technologies</a></li> <li><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </li> <li><a href="#">Examples</a> <ul> <li><a href="all-examples.html">Examples</a></li> <li><a href="tutorials.html">Tutorials</a></li> <li><a href="demos.html">Demos</a></li> <li><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </li> </ul> </div> </div> <div class="wrapper"> <div class="hd"> <span></span> </div> <div class="bd group"> <div class="sidebar"> <div class="searchlabel"> Search index:</div> <div class="search" id="sidebarsearch"> <form id="qtdocsearch" action="" onsubmit="return false;"> <fieldset> <input type="text" name="searchstring" id="pageType" value="" /> <div id="resultdialog"> <a href="#" id="resultclose">Close</a> <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span> results:</p> <ul id="resultlist" class="all"> </ul> </div> </fieldset> </form> </div> <div class="box first bottombar" id="lookup"> <h2 title="API Lookup"><span></span> API Lookup</h2> <div id="list001" class="list"> <ul id="ul001" > <li class="defaultLink"><a href="classes.html">Class index</a></li> <li class="defaultLink"><a href="functions.html">Function index</a></li> <li class="defaultLink"><a href="modules.html">Modules</a></li> <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li> <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li> <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </div> </div> <div class="box bottombar" id="topics"> <h2 title="Qt Topics"><span></span> Qt Topics</h2> <div id="list002" class="list"> <ul id="ul002" > <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li class="defaultLink"><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li> <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </div> </div> <div class="box" id="examples"> <h2 title="Examples"><span></span> Examples</h2> <div id="list003" class="list"> <ul id="ul003"> <li class="defaultLink"><a href="all-examples.html">Examples</a></li> <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li> <li class="defaultLink"><a href="demos.html">Demos</a></li> <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </div> </div> </div> <div class="wrap"> <div class="toolbar"> <div class="breadcrumb toolblock"> <ul> <li class="first"><a href="index.html">Home</a></li> <!-- Breadcrumbs go here --> <li><a href="modules.html">Modules</a></li> <li><a href="qtopengl.html">QtOpenGL</a></li> <li>QGLColormap</li> </ul> </div> <div class="toolbuttons toolblock"> <ul> <li id="smallA" class="t_button">A</li> <li id="medA" class="t_button active">A</li> <li id="bigA" class="t_button">A</li> <li id="print" class="t_button"><a href="javascript:this.print();"> <span>Print</span></a></li> </ul> </div> </div> <div class="content mainContent"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <h1 class="title">QGLColormap Class Reference</h1> <!-- $$$QGLColormap-brief --> <p>The QGLColormap class is used for installing custom colormaps into a <a href="qglwidget.html">QGLWidget</a>. <a href="#details">More...</a></p> <!-- @@@QGLColormap --> <pre class="cpp"> <span class="preprocessor">#include <QGLColormap></span></pre><ul> <li><a href="qglcolormap-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h2>Public Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#QGLColormap">QGLColormap</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#QGLColormap-2">QGLColormap</a></b> ( const QGLColormap & <i>map</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#dtor.QGLColormap">~QGLColormap</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QColor </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#entryColor">entryColor</a></b> ( int <i>idx</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QRgb </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#entryRgb">entryRgb</a></b> ( int <i>idx</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#find">find</a></b> ( QRgb <i>color</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#findNearest">findNearest</a></b> ( QRgb <i>color</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#isEmpty">isEmpty</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#setEntries">setEntries</a></b> ( int <i>count</i>, const QRgb * <i>colors</i>, int <i>base</i> = 0 )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#setEntry">setEntry</a></b> ( int <i>idx</i>, QRgb <i>color</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#setEntry-2">setEntry</a></b> ( int <i>idx</i>, const QColor & <i>color</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#size">size</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QGLColormap & </td><td class="memItemRight bottomAlign"><b><a href="qglcolormap.html#operator-eq">operator=</a></b> ( const QGLColormap & <i>map</i> )</td></tr> </table> <a name="details"></a> <!-- $$$QGLColormap-description --> <div class="descr"> <h2>Detailed Description</h2> <p>The QGLColormap class is used for installing custom colormaps into a <a href="qglwidget.html">QGLWidget</a>.</p> <p>QGLColormap provides a platform independent way of specifying and installing indexed colormaps for a <a href="qglwidget.html">QGLWidget</a>. QGLColormap is especially useful when using the OpenGL color-index mode.</p> <p>Under X11 you must use an X server that supports either a <tt>PseudoColor</tt> or <tt>DirectColor</tt> visual class. If your X server currently only provides a <tt>GrayScale</tt>, <tt>TrueColor</tt>, <tt>StaticColor</tt> or <tt>StaticGray</tt> 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 <tt>PseudoColor</tt> visual. Note that you may experience colormap flashing if your X server is running in 8 bit mode.</p> <p>The <a href="qglcolormap.html#size">size</a>() of the colormap is always set to 256 colors. Note that under Windows you can also install colormaps in child widgets.</p> <p>This class uses <a href="implicit-sharing.html">implicit sharing</a> as a memory and speed optimization.</p> <p>Example of use:</p> <pre class="cpp"> <span class="preprocessor">#include <QApplication></span> <span class="preprocessor">#include <QGLColormap></span> <span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>) { <span class="type"><a href="qapplication.html">QApplication</a></span> app(argc<span class="operator">,</span> argv); MySuperGLWidget widget; <span class="comment">// a QGLWidget in color-index mode</span> <span class="type">QGLColormap</span> colormap; <span class="comment">// This will fill the colormap with colors ranging from</span> <span class="comment">// black to white.</span> <span class="keyword">const</span> <span class="type">int</span> size <span class="operator">=</span> <span class="number">256</span>; <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator"><</span> size; <span class="operator">+</span><span class="operator">+</span>i) colormap<span class="operator">.</span>setEntry(i<span class="operator">,</span> <a href="qcolor.html#qRgb">qRgb</a>(i<span class="operator">,</span> i<span class="operator">,</span> i)); widget<span class="operator">.</span>setColormap(colormap); widget<span class="operator">.</span>show(); <span class="keyword">return</span> app<span class="operator">.</span>exec(); }</pre> </div> <p><b>See also </b><a href="qglwidget.html#setColormap">QGLWidget::setColormap</a>() and <a href="qglwidget.html#colormap">QGLWidget::colormap</a>().</p> <!-- @@@QGLColormap --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QGLColormap[overload1]$$$QGLColormap --> <h3 class="fn"><a name="QGLColormap"></a>QGLColormap::<span class="name">QGLColormap</span> ()</h3> <p>Construct a <a href="qglcolormap.html">QGLColormap</a>.</p> <!-- @@@QGLColormap --> <!-- $$$QGLColormap$$$QGLColormapconstQGLColormap& --> <h3 class="fn"><a name="QGLColormap-2"></a>QGLColormap::<span class="name">QGLColormap</span> ( const <span class="type">QGLColormap</span> & <i>map</i> )</h3> <p>Construct a shallow copy of <i>map</i>.</p> <!-- @@@QGLColormap --> <!-- $$$~QGLColormap[overload1]$$$~QGLColormap --> <h3 class="fn"><a name="dtor.QGLColormap"></a>QGLColormap::<span class="name">~QGLColormap</span> ()</h3> <p>Dereferences the <a href="qglcolormap.html">QGLColormap</a> and deletes it if this was the last reference to it.</p> <!-- @@@~QGLColormap --> <!-- $$$entryColor[overload1]$$$entryColorint --> <h3 class="fn"><a name="entryColor"></a><span class="type"><a href="qcolor.html">QColor</a></span> QGLColormap::<span class="name">entryColor</span> ( <span class="type">int</span> <i>idx</i> ) const</h3> <p>Returns the <a href="qcolor.html#QRgb-typedef">QRgb</a> value in the colorcell with index <i>idx</i>.</p> <!-- @@@entryColor --> <!-- $$$entryRgb[overload1]$$$entryRgbint --> <h3 class="fn"><a name="entryRgb"></a><span class="type"><a href="qcolor.html#QRgb-typedef">QRgb</a></span> QGLColormap::<span class="name">entryRgb</span> ( <span class="type">int</span> <i>idx</i> ) const</h3> <p>Returns the <a href="qcolor.html#QRgb-typedef">QRgb</a> value in the colorcell with index <i>idx</i>.</p> <!-- @@@entryRgb --> <!-- $$$find[overload1]$$$findQRgb --> <h3 class="fn"><a name="find"></a><span class="type">int</span> QGLColormap::<span class="name">find</span> ( <span class="type"><a href="qcolor.html#QRgb-typedef">QRgb</a></span> <i>color</i> ) const</h3> <p>Returns the index of the color <i>color</i>. If <i>color</i> is not in the map, -1 is returned.</p> <!-- @@@find --> <!-- $$$findNearest[overload1]$$$findNearestQRgb --> <h3 class="fn"><a name="findNearest"></a><span class="type">int</span> QGLColormap::<span class="name">findNearest</span> ( <span class="type"><a href="qcolor.html#QRgb-typedef">QRgb</a></span> <i>color</i> ) const</h3> <p>Returns the index of the color that is the closest match to color <i>color</i>.</p> <!-- @@@findNearest --> <!-- $$$isEmpty[overload1]$$$isEmpty --> <h3 class="fn"><a name="isEmpty"></a><span class="type">bool</span> QGLColormap::<span class="name">isEmpty</span> () const</h3> <p>Returns true if the colormap is empty or it is not in use by a <a href="qglwidget.html">QGLWidget</a>; otherwise returns false.</p> <p>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 <a href="qglwidget.html">QGLWidget</a> is also considered empty.</p> <p>Compare <a href="qglcolormap.html#size">size</a>() with zero to determine if the colormap is empty regardless of whether it is in use by a <a href="qglwidget.html">QGLWidget</a> or not.</p> <p><b>See also </b><a href="qglcolormap.html#size">size</a>().</p> <!-- @@@isEmpty --> <!-- $$$setEntries[overload1]$$$setEntriesintconstQRgb*int --> <h3 class="fn"><a name="setEntries"></a><span class="type">void</span> QGLColormap::<span class="name">setEntries</span> ( <span class="type">int</span> <i>count</i>, const <span class="type"><a href="qcolor.html#QRgb-typedef">QRgb</a></span> * <i>colors</i>, <span class="type">int</span> <i>base</i> = 0 )</h3> <p>Set an array of cells in this colormap. <i>count</i> is the number of colors that should be set, <i>colors</i> is the array of colors, and <i>base</i> is the starting index. The first element in <i>colors</i> is set at <i>base</i> in the colormap.</p> <!-- @@@setEntries --> <!-- $$$setEntry[overload1]$$$setEntryintQRgb --> <h3 class="fn"><a name="setEntry"></a><span class="type">void</span> QGLColormap::<span class="name">setEntry</span> ( <span class="type">int</span> <i>idx</i>, <span class="type"><a href="qcolor.html#QRgb-typedef">QRgb</a></span> <i>color</i> )</h3> <p>Set cell at index <i>idx</i> in the colormap to color <i>color</i>.</p> <!-- @@@setEntry --> <!-- $$$setEntry$$$setEntryintconstQColor& --> <h3 class="fn"><a name="setEntry-2"></a><span class="type">void</span> QGLColormap::<span class="name">setEntry</span> ( <span class="type">int</span> <i>idx</i>, const <span class="type"><a href="qcolor.html">QColor</a></span> & <i>color</i> )</h3> <p>This is an overloaded function.</p> <p>Set the cell with index <i>idx</i> in the colormap to color <i>color</i>.</p> <!-- @@@setEntry --> <!-- $$$size[overload1]$$$size --> <h3 class="fn"><a name="size"></a><span class="type">int</span> QGLColormap::<span class="name">size</span> () const</h3> <p>Returns the number of colorcells in the colormap.</p> <!-- @@@size --> <!-- $$$operator=[overload1]$$$operator=constQGLColormap& --> <h3 class="fn"><a name="operator-eq"></a><span class="type">QGLColormap</span> & QGLColormap::<span class="name">operator=</span> ( const <span class="type">QGLColormap</span> & <i>map</i> )</h3> <p>Assign a shallow copy of <i>map</i> to this <a href="qglcolormap.html">QGLColormap</a>.</p> <!-- @@@operator= --> </div> </div> </div> </div> <div class="ft"> <span></span> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2015 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.</p> <br /> <p> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.</p> <p> Documentation sources may be obtained from <a href="http://www.qt-project.org"> www.qt-project.org</a>.</p> <br /> <p> 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. <a title="Privacy Policy" href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p> </div> <script src="scripts/functions.js" type="text/javascript"></script> </body> </html>