1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QGLWidget Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QGLWidget Class Reference<br /><sup><sup>[<a href="qtopengl.html">QtOpenGL</a> module]</sup></sup></h1><p>The QGLWidget class is a widget for rendering OpenGL graphics. <a href="#details">More...</a></p>
<p>Inherits <a href="qwidget.html">QWidget</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qglwidget.html#QGLWidget">__init__</a></b> (<i>self</i>, QWidget <i>parent</i> = None, QGLWidget <i>shareWidget</i> = None, Qt.WindowFlags <i>f</i> = 0)</li><li><div class="fn" /><b><a href="qglwidget.html#QGLWidget-2">__init__</a></b> (<i>self</i>, QGLContext <i>context</i>, QWidget <i>parent</i> = None, QGLWidget <i>shareWidget</i> = None, Qt.WindowFlags <i>f</i> = 0)</li><li><div class="fn" /><b><a href="qglwidget.html#QGLWidget-3">__init__</a></b> (<i>self</i>, QGLFormat <i>format</i>, QWidget <i>parent</i> = None, QGLWidget <i>shareWidget</i> = None, Qt.WindowFlags <i>f</i> = 0)</li><li><div class="fn" />bool <b><a href="qglwidget.html#autoBufferSwap">autoBufferSwap</a></b> (<i>self</i>)</li><li><div class="fn" />unsigned long <b><a href="qglwidget.html#bindTexture">bindTexture</a></b> (<i>self</i>, QImage <i>image</i>, unsigned long <i>target</i> = GL_TEXTURE_2D, int <i>format</i> = GL_RGBA8)</li><li><div class="fn" />unsigned long <b><a href="qglwidget.html#bindTexture-2">bindTexture</a></b> (<i>self</i>, QPixmap <i>pixmap</i>, unsigned long <i>target</i> = GL_TEXTURE_2D, int <i>format</i> = GL_RGBA8)</li><li><div class="fn" />unsigned long <b><a href="qglwidget.html#bindTexture-3">bindTexture</a></b> (<i>self</i>, QString <i>fileName</i>)</li><li><div class="fn" />QGLColormap <b><a href="qglwidget.html#colormap">colormap</a></b> (<i>self</i>)</li><li><div class="fn" />QGLContext <b><a href="qglwidget.html#context">context</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#deleteTexture">deleteTexture</a></b> (<i>self</i>, unsigned long <i>tx_id</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#doneCurrent">doneCurrent</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qglwidget.html#doubleBuffer">doubleBuffer</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qglwidget.html#event">event</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" />int <b><a href="qglwidget.html#fontDisplayListBase">fontDisplayListBase</a></b> (<i>self</i>, QFont <i>fnt</i>, int <i>listBase</i> = 2000)</li><li><div class="fn" />QGLFormat <b><a href="qglwidget.html#format">format</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#glDraw">glDraw</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#glInit">glInit</a></b> (<i>self</i>)</li><li><div class="fn" />QImage <b><a href="qglwidget.html#grabFrameBuffer">grabFrameBuffer</a></b> (<i>self</i>, bool <i>withAlpha</i> = False)</li><li><div class="fn" /><b><a href="qglwidget.html#initializeGL">initializeGL</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#initializeOverlayGL">initializeOverlayGL</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qglwidget.html#isSharing">isSharing</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qglwidget.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#makeCurrent">makeCurrent</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#makeOverlayCurrent">makeOverlayCurrent</a></b> (<i>self</i>)</li><li><div class="fn" />QGLContext <b><a href="qglwidget.html#overlayContext">overlayContext</a></b> (<i>self</i>)</li><li><div class="fn" />QPaintEngine <b><a href="qglwidget.html#paintEngine">paintEngine</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#paintEvent">paintEvent</a></b> (<i>self</i>, QPaintEvent)</li><li><div class="fn" /><b><a href="qglwidget.html#paintGL">paintGL</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#paintOverlayGL">paintOverlayGL</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#qglClearColor">qglClearColor</a></b> (<i>self</i>, QColor <i>c</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#qglColor">qglColor</a></b> (<i>self</i>, QColor <i>c</i>)</li><li><div class="fn" />QPixmap <b><a href="qglwidget.html#renderPixmap">renderPixmap</a></b> (<i>self</i>, int <i>w</i> = 0, int <i>h</i> = 0, bool <i>useContext</i> = False)</li><li><div class="fn" /><b><a href="qglwidget.html#renderText">renderText</a></b> (<i>self</i>, int <i>x</i>, int <i>y</i>, QString <i>str</i>, QFont <i>fnt</i> = QFont(), int <i>listBase</i> = 2000)</li><li><div class="fn" /><b><a href="qglwidget.html#renderText-2">renderText</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>z</i>, QString <i>str</i>, QFont <i>fnt</i> = QFont(), int <i>listBase</i> = 2000)</li><li><div class="fn" /><b><a href="qglwidget.html#resizeEvent">resizeEvent</a></b> (<i>self</i>, QResizeEvent)</li><li><div class="fn" /><b><a href="qglwidget.html#resizeGL">resizeGL</a></b> (<i>self</i>, int <i>w</i>, int <i>h</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#resizeOverlayGL">resizeOverlayGL</a></b> (<i>self</i>, int <i>w</i>, int <i>h</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#setAutoBufferSwap">setAutoBufferSwap</a></b> (<i>self</i>, bool <i>on</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#setColormap">setColormap</a></b> (<i>self</i>, QGLColormap <i>map</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#setContext">setContext</a></b> (<i>self</i>, QGLContext <i>context</i>, QGLContext <i>shareContext</i> = None, bool <i>deleteOldContext</i> = True)</li><li><div class="fn" /><b><a href="qglwidget.html#setFormat">setFormat</a></b> (<i>self</i>, QGLFormat <i>format</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#setMouseTracking">setMouseTracking</a></b> (<i>self</i>, bool <i>enable</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#swapBuffers">swapBuffers</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#updateGL">updateGL</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qglwidget.html#updateOverlayGL">updateOverlayGL</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />QImage <b><a href="qglwidget.html#convertToGLFormat">convertToGLFormat</a></b> (QImage <i>img</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QGLWidget class is a widget for rendering OpenGL graphics.</p>
<p>QGLWidget provides functionality for displaying OpenGL graphics integrated into a Qt application. It is very simple to use. You inherit from it and use the subclass like any other <a href="qwidget.html">QWidget</a>, except that instead of drawing the widget's contents using <a href="qpainter.html">QPainter</a> you use the standard OpenGL rendering commands.</p>
<p>QGLWidget provides three convenient virtual functions that you can reimplement in your subclass to perform the typical OpenGL tasks:</p>
<ul>
<li><a href="qglwidget.html#paintGL">paintGL</a>() - Renders the OpenGL scene. Gets called whenever the widget needs to be updated.</li>
<li><a href="qglwidget.html#resizeGL">resizeGL</a>() - Sets up the OpenGL viewport, projection, etc. Gets called whenever the the widget has been resized (and also when it is shown for the first time because all newly created widgets get a resize event automatically).</li>
<li><a href="qglwidget.html#initializeGL">initializeGL</a>() - Sets up the OpenGL rendering context, defines display lists, etc. Gets called once before the first time <a href="qglwidget.html#resizeGL">resizeGL</a>() or <a href="qglwidget.html#paintGL">paintGL</a>() is called.</li>
</ul>
<p>Here is a rough outline of how a QGLWidget subclass might look:</p>
<pre>
class MyGLDrawer : public QGLWidget
{
Q_OBJECT // must include this if you use Qt signals/slots
public:
MyGLDrawer(QWidget *parent)
: QGLWidget(parent) {}
protected:
void initializeGL()
{
// Set up the rendering context, define display lists etc.:
...
glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
...
}
void resizeGL(int w, int h)
{
// setup viewport, projection etc.:
glViewport(0, 0, (GLint)w, (GLint)h);
...
glFrustum(...);
...
}
void paintGL()
{
// draw the scene:
...
glRotatef(...);
glMaterialfv(...);
glBegin(GL_QUADS);
glVertex3f(...);
glVertex3f(...);
...
glEnd();
...
}
};
</pre>
<p>If you need to trigger a repaint from places other than <a href="qglwidget.html#paintGL">paintGL</a>() (a typical example is when using <a href="qtimer.html">timers</a> to animate scenes), you should call the widget's <a href="qglwidget.html#updateGL">updateGL</a>() function.</p>
<p>Your widget's OpenGL rendering context is made current when <a href="qglwidget.html#paintGL">paintGL</a>(), <a href="qglwidget.html#resizeGL">resizeGL</a>(), or <a href="qglwidget.html#initializeGL">initializeGL</a>() is called. If you need to call the standard OpenGL API functions from other places (e.g. in your widget's constructor or in your own paint functions), you must call <a href="qglwidget.html#makeCurrent">makeCurrent</a>() first.</p>
<p>QGLWidget provides functions for requesting a new display <a href="qglformat.html">format</a> and you can also create widgets with customized rendering <a href="qglcontext.html">contexts</a>.</p>
<p>You can also share OpenGL display lists between QGLWidgets (see the documentation of the QGLWidget constructors for details).</p>
<a id="overlays" name="overlays" />
<h3>Overlays</h3>
<p>The QGLWidget creates a GL overlay context in addition to the normal context if overlays are supported by the underlying system.</p>
<p>If you want to use overlays, you specify it in the <a href="qglformat.html">format</a>. (Note: Overlay must be requested in the format passed to the QGLWidget constructor.) Your GL widget should also implement some or all of these virtual methods:</p>
<ul>
<li><a href="qglwidget.html#paintOverlayGL">paintOverlayGL</a>()</li>
<li><a href="qglwidget.html#resizeOverlayGL">resizeOverlayGL</a>()</li>
<li><a href="qglwidget.html#initializeOverlayGL">initializeOverlayGL</a>()</li>
</ul>
<p>These methods work in the same way as the normal <a href="qglwidget.html#paintGL">paintGL</a>() etc. functions, except that they will be called when the overlay context is made current. You can explicitly make the overlay context current by using <a href="qglwidget.html#makeOverlayCurrent">makeOverlayCurrent</a>(), and you can access the overlay context directly (e.g. to ask for its transparent color) by calling <a href="qglwidget.html#overlayContext">overlayContext</a>().</p>
<p>On X servers in which the default visual is in an overlay plane, non-GL Qt windows can also be used for overlays.</p>
<a id="painting-techniques" name="painting-techniques" />
<h3>Painting Techniques</h3>
<p>As described above, subclass QGLWidget to render pure 3D content in the following way:</p>
<ul>
<li>Reimplement the <a href="qglwidget.html#initializeGL">QGLWidget.initializeGL</a>() and <a href="qglwidget.html#resizeGL">QGLWidget.resizeGL</a>() to set up the OpenGL state and provide a perspective transformation.</li>
<li>Reimplement <a href="qglwidget.html#paintGL">QGLWidget.paintGL</a>() to paint the 3D scene, calling only OpenGL functions to draw on the widget.</li>
</ul>
<p>It is also possible to draw 2D graphics onto a QGLWidget subclass, it is necessary to reimplement <a href="qglwidget.html#paintEvent">QGLWidget.paintEvent</a>() and do the following:</p>
<ul>
<li>Construct a <a href="qpainter.html">QPainter</a> object.</li>
<li>Initialize it for use on the widget with the <a href="qpainter.html#begin">QPainter.begin</a>() function.</li>
<li>Draw primitives using <a href="qpainter.html">QPainter</a>'s member functions.</li>
<li>Call <a href="qpainter.html#end">QPainter.end</a>() to finish painting.</li>
</ul>
<p>Overpainting 2D content on top of 3D content takes a little more effort. One approach to doing this is shown in the <a href="opengl-overpainting.html">Overpainting</a> example.</p>
<p><i>OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other countries.</i></p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QGLWidget" />QGLWidget.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>parent</i> = None, <a href="qglwidget.html">QGLWidget</a> <i>shareWidget</i> = None, <a href="qt-windowflags.html">Qt.WindowFlags</a> <i>f</i> = 0)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs an OpenGL widget with a <i>parent</i> widget.</p>
<p>The <a href="qglformat.html#defaultFormat">default format</a> is used. The widget will be <a href="qglwidget.html#isValid">invalid</a> if the system has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.</p>
<p>The <i>parent</i> and widget flag, <i>f</i>, arguments are passed to the <a href="qwidget.html">QWidget</a> constructor.</p>
<p>If the <i>shareWidget</i> parameter points to a valid <a href="qglwidget.html">QGLWidget</a>, this widget will share OpenGL display lists with <i>shareWidget</i>. If this widget and <i>shareWidget</i> have different <a href="qglwidget.html#format">formats</a>, display list sharing may fail. You can check whether display list sharing succeeded by calling <a href="qglwidget.html#isSharing">isSharing</a>().</p>
<p>The initialization of OpenGL rendering state, etc. should be done by overriding the <a href="qglwidget.html#initializeGL">initializeGL</a>() function, rather than in the constructor of your <a href="qglwidget.html">QGLWidget</a> subclass.</p>
<p>See also <a href="qglformat.html#defaultFormat">QGLFormat.defaultFormat</a>().</p>
<h3 class="fn"><a name="QGLWidget-2" />QGLWidget.__init__ (<i>self</i>, <a href="qglcontext.html">QGLContext</a> <i>context</i>, <a href="qwidget.html">QWidget</a> <i>parent</i> = None, <a href="qglwidget.html">QGLWidget</a> <i>shareWidget</i> = None, <a href="qt-windowflags.html">Qt.WindowFlags</a> <i>f</i> = 0)</h3><p>The <i>context</i> argument has it's ownership transferred to Qt.</p><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs an OpenGL widget with parent <i>parent</i>.</p>
<p>The <i>context</i> argument is a pointer to the <a href="qglcontext.html">QGLContext</a> that you wish to be bound to this widget. This allows you to pass in your own <a href="qglcontext.html">QGLContext</a> sub-classes.</p>
<p>The widget will be <a href="qglwidget.html#isValid">invalid</a> if the system has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.</p>
<p>The <i>parent</i> and widget flag, <i>f</i>, arguments are passed to the <a href="qwidget.html">QWidget</a> constructor.</p>
<p>If the <i>shareWidget</i> parameter points to a valid <a href="qglwidget.html">QGLWidget</a>, this widget will share OpenGL display lists with <i>shareWidget</i>. If this widget and <i>shareWidget</i> have different <a href="qglwidget.html#format">formats</a>, display list sharing may fail. You can check whether display list sharing succeeded by calling <a href="qglwidget.html#isSharing">isSharing</a>().</p>
<p>The initialization of OpenGL rendering state, etc. should be done by overriding the <a href="qglwidget.html#initializeGL">initializeGL</a>() function, rather than in the constructor of your <a href="qglwidget.html">QGLWidget</a> subclass.</p>
<p>See also <a href="qglformat.html#defaultFormat">QGLFormat.defaultFormat</a>() and <a href="qglwidget.html#isValid">isValid</a>().</p>
<h3 class="fn"><a name="QGLWidget-3" />QGLWidget.__init__ (<i>self</i>, <a href="qglformat.html">QGLFormat</a> <i>format</i>, <a href="qwidget.html">QWidget</a> <i>parent</i> = None, <a href="qglwidget.html">QGLWidget</a> <i>shareWidget</i> = None, <a href="qt-windowflags.html">Qt.WindowFlags</a> <i>f</i> = 0)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs an OpenGL widget with parent <i>parent</i>.</p>
<p>The <i>format</i> argument specifies the desired <a href="qglformat.html">rendering options</a>. If the underlying OpenGL/Window system cannot satisfy all the features requested in <i>format</i>, the nearest subset of features will be used. After creation, the <a href="qglwidget.html#format">format</a>() method will return the actual format obtained.</p>
<p>The widget will be <a href="qglwidget.html#isValid">invalid</a> if the system has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.</p>
<p>The <i>parent</i> and widget flag, <i>f</i>, arguments are passed to the <a href="qwidget.html">QWidget</a> constructor.</p>
<p>If the <i>shareWidget</i> parameter points to a valid <a href="qglwidget.html">QGLWidget</a>, this widget will share OpenGL display lists with <i>shareWidget</i>. If this widget and <i>shareWidget</i> have different <a href="qglwidget.html#format">formats</a>, display list sharing may fail. You can check whether display list sharing succeeded by calling <a href="qglwidget.html#isSharing">isSharing</a>().</p>
<p>The initialization of OpenGL rendering state, etc. should be done by overriding the <a href="qglwidget.html#initializeGL">initializeGL</a>() function, rather than in the constructor of your <a href="qglwidget.html">QGLWidget</a> subclass.</p>
<p>See also <a href="qglformat.html#defaultFormat">QGLFormat.defaultFormat</a>() and <a href="qglwidget.html#isValid">isValid</a>().</p>
<h3 class="fn"><a name="autoBufferSwap" />bool QGLWidget.autoBufferSwap (<i>self</i>)</h3><p>Returns true if the widget is doing automatic GL buffer swapping; otherwise returns false.</p>
<p>See also <a href="qglwidget.html#setAutoBufferSwap">setAutoBufferSwap</a>().</p>
<h3 class="fn"><a name="bindTexture" />unsigned long QGLWidget.bindTexture (<i>self</i>, <a href="qimage.html">QImage</a> <i>image</i>, unsigned long <i>target</i> = GL_TEXTURE_2D, int <i>format</i> = GL_RGBA8)</h3><p>Calls QGLContext.:bindTexture(<i>image</i>, <i>target</i>, <i>format</i>) on the currently set context.</p>
<p>See also <a href="qglwidget.html#deleteTexture">deleteTexture</a>().</p>
<h3 class="fn"><a name="bindTexture-2" />unsigned long QGLWidget.bindTexture (<i>self</i>, <a href="qpixmap.html">QPixmap</a> <i>pixmap</i>, unsigned long <i>target</i> = GL_TEXTURE_2D, int <i>format</i> = GL_RGBA8)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Calls QGLContext.:bindTexture(<i>pixmap</i>, <i>target</i>, <i>format</i>) on the currently set context.</p>
<p>See also <a href="qglwidget.html#deleteTexture">deleteTexture</a>().</p>
<h3 class="fn"><a name="bindTexture-3" />unsigned long QGLWidget.bindTexture (<i>self</i>, <a href="qstring.html">QString</a> <i>fileName</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Calls QGLContext.bindTexture(<i>fileName</i>) on the currently set context.</p>
<p>See also <a href="qglwidget.html#deleteTexture">deleteTexture</a>().</p>
<h3 class="fn"><a name="colormap" /><a href="qglcolormap.html">QGLColormap</a> QGLWidget.colormap (<i>self</i>)</h3><p>Returns the colormap for this widget.</p>
<p>Usually it is only top-level widgets that can have different colormaps installed. Asking for the colormap of a child widget will return the colormap for the child's top-level widget.</p>
<p>If no colormap has been set for this widget, the <a href="qcolormap.html">QColormap</a> returned will be empty.</p>
<p>See also <a href="qglwidget.html#setColormap">setColormap</a>().</p>
<h3 class="fn"><a name="context" /><a href="qglcontext.html">QGLContext</a> QGLWidget.context (<i>self</i>)</h3><p>Returns the context of this widget.</p>
<p>It is possible that the context is not valid (see <a href="qglwidget.html#isValid">isValid</a>()), for example, if the underlying hardware does not support the format attributes that were requested.</p>
<h3 class="fn"><a name="convertToGLFormat" /><a href="qimage.html">QImage</a> QGLWidget.convertToGLFormat (<a href="qimage.html">QImage</a> <i>img</i>)</h3><p>Converts the image <i>img</i> into the unnamed format expected by OpenGL functions such as glTexImage2D(). The returned image is not usable as a <a href="qimage.html">QImage</a>, but <a href="qimage.html#width">QImage.width</a>(), <a href="qimage.html#height">QImage.height</a>() and <a href="qimage.html#bits">QImage.bits</a>() may be used with OpenGL.</p>
<h3 class="fn"><a name="deleteTexture" />QGLWidget.deleteTexture (<i>self</i>, unsigned long <i>tx_id</i>)</h3><p>Calls QGLContext.deleteTexture(<i>id</i>) on the currently set context.</p>
<p>See also <a href="qglwidget.html#bindTexture">bindTexture</a>().</p>
<h3 class="fn"><a name="doneCurrent" />QGLWidget.doneCurrent (<i>self</i>)</h3><p>Makes no GL context the current context. Normally, you do not need to call this function; <a href="qglcontext.html">QGLContext</a> calls it as necessary. However, it may be useful in multithreaded environments.</p>
<h3 class="fn"><a name="doubleBuffer" />bool QGLWidget.doubleBuffer (<i>self</i>)</h3><p>Returns true if the contained GL rendering context has double buffering; otherwise returns false.</p>
<p>See also <a href="qglformat.html#doubleBuffer">QGLFormat.doubleBuffer</a>().</p>
<h3 class="fn"><a name="event" />bool QGLWidget.event (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><h3 class="fn"><a name="fontDisplayListBase" />int QGLWidget.fontDisplayListBase (<i>self</i>, <a href="qfont.html">QFont</a> <i>fnt</i>, int <i>listBase</i> = 2000)</h3><p>Returns the value of the first display list that is generated for the characters in font <i>fnt</i>. <i>listBase</i> indicates the base value used when generating the display lists for the font. The default value is 2000.</p>
<h3 class="fn"><a name="format" /><a href="qglformat.html">QGLFormat</a> QGLWidget.format (<i>self</i>)</h3><p>Returns the format of the contained GL rendering context.</p>
<p>See also <a href="qglwidget-obsolete.html#setFormat">setFormat</a>().</p>
<h3 class="fn"><a name="glDraw" />QGLWidget.glDraw (<i>self</i>)</h3><p>Executes the virtual function <a href="qglwidget.html#paintGL">paintGL</a>().</p>
<p>The widget's rendering context will become the current context and <a href="qglwidget.html#initializeGL">initializeGL</a>() will be called if it hasn't already been called.</p>
<h3 class="fn"><a name="glInit" />QGLWidget.glInit (<i>self</i>)</h3><p>Initializes OpenGL for this widget's context. Calls the virtual function <a href="qglwidget.html#initializeGL">initializeGL</a>().</p>
<h3 class="fn"><a name="grabFrameBuffer" /><a href="qimage.html">QImage</a> QGLWidget.grabFrameBuffer (<i>self</i>, bool <i>withAlpha</i> = False)</h3><p>Returns an image of the frame buffer. If <i>withAlpha</i> is true the alpha channel is included.</p>
<p>Depending on your hardware, you can explicitly select which color buffer to grab with a glReadBuffer() call before calling this function.</p>
<h3 class="fn"><a name="initializeGL" />QGLWidget.initializeGL (<i>self</i>)</h3><p>This virtual function is called once before the first call to <a href="qglwidget.html#paintGL">paintGL</a>() or <a href="qglwidget.html#resizeGL">resizeGL</a>(), and then once whenever the widget has been assigned a new <a href="qglcontext.html">QGLContext</a>. Reimplement it in a subclass.</p>
<p>This function should set up any required OpenGL context rendering flags, defining display lists, etc.</p>
<p>There is no need to call <a href="qglwidget.html#makeCurrent">makeCurrent</a>() because this has already been done when this function is called.</p>
<h3 class="fn"><a name="initializeOverlayGL" />QGLWidget.initializeOverlayGL (<i>self</i>)</h3><p>This virtual function is used in the same manner as <a href="qglwidget.html#initializeGL">initializeGL</a>() except that it operates on the widget's overlay context instead of the widget's main context. This means that initializeOverlayGL() is called once before the first call to <a href="qglwidget.html#paintOverlayGL">paintOverlayGL</a>() or <a href="qglwidget.html#resizeOverlayGL">resizeOverlayGL</a>(). Reimplement it in a subclass.</p>
<p>This function should set up any required OpenGL context rendering flags, defining display lists, etc. for the overlay context.</p>
<p>There is no need to call <a href="qglwidget.html#makeOverlayCurrent">makeOverlayCurrent</a>() because this has already been done when this function is called.</p>
<h3 class="fn"><a name="isSharing" />bool QGLWidget.isSharing (<i>self</i>)</h3><p>Returns true if this widget's GL context is shared with another GL context, otherwise false is returned. The GL system may fail to provide context sharing if the two QGLWidgets use different formats.</p>
<p>See also <a href="qglwidget.html#format">format</a>().</p>
<h3 class="fn"><a name="isValid" />bool QGLWidget.isValid (<i>self</i>)</h3><p>Returns true if the widget has a valid GL rendering context; otherwise returns false. A widget will be invalid if the system has no <a href="qglformat.html#hasOpenGL">OpenGL support</a>.</p>
<h3 class="fn"><a name="makeCurrent" />QGLWidget.makeCurrent (<i>self</i>)</h3><p>Makes this widget the current widget for OpenGL operations, i.e. makes the widget's rendering context the current OpenGL rendering context.</p>
<h3 class="fn"><a name="makeOverlayCurrent" />QGLWidget.makeOverlayCurrent (<i>self</i>)</h3><p>Makes the overlay context of this widget current. Use this if you need to issue OpenGL commands to the overlay context outside of <a href="qglwidget.html#initializeOverlayGL">initializeOverlayGL</a>(), <a href="qglwidget.html#resizeOverlayGL">resizeOverlayGL</a>(), and <a href="qglwidget.html#paintOverlayGL">paintOverlayGL</a>().</p>
<p>Does nothing if this widget has no overlay.</p>
<p>See also <a href="qglwidget.html#makeCurrent">makeCurrent</a>().</p>
<h3 class="fn"><a name="overlayContext" /><a href="qglcontext.html">QGLContext</a> QGLWidget.overlayContext (<i>self</i>)</h3><p>Returns the overlay context of this widget, or 0 if this widget has no overlay.</p>
<p>See also <a href="qglwidget.html#context">context</a>().</p>
<h3 class="fn"><a name="paintEngine" /><a href="qpaintengine.html">QPaintEngine</a> QGLWidget.paintEngine (<i>self</i>)</h3><h3 class="fn"><a name="paintEvent" />QGLWidget.paintEvent (<i>self</i>, <a href="qpaintevent.html">QPaintEvent</a>)</h3><p>Handles paint events passed in the <i>event</i> parameter. Will cause the virtual <a href="qglwidget.html#paintGL">paintGL</a>() function to be called.</p>
<p>The widget's rendering context will become the current context and <a href="qglwidget.html#initializeGL">initializeGL</a>() will be called if it hasn't already been called.</p>
<p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget</a>.</p>
<h3 class="fn"><a name="paintGL" />QGLWidget.paintGL (<i>self</i>)</h3><p>This virtual function is called whenever the widget needs to be painted. Reimplement it in a subclass.</p>
<p>There is no need to call <a href="qglwidget.html#makeCurrent">makeCurrent</a>() because this has already been done when this function is called.</p>
<h3 class="fn"><a name="paintOverlayGL" />QGLWidget.paintOverlayGL (<i>self</i>)</h3><p>This virtual function is used in the same manner as <a href="qglwidget.html#paintGL">paintGL</a>() except that it operates on the widget's overlay context instead of the widget's main context. This means that paintOverlayGL() is called whenever the widget's overlay needs to be painted. Reimplement it in a subclass.</p>
<p>There is no need to call <a href="qglwidget.html#makeOverlayCurrent">makeOverlayCurrent</a>() because this has already been done when this function is called.</p>
<h3 class="fn"><a name="qglClearColor" />QGLWidget.qglClearColor (<i>self</i>, <a href="qcolor.html">QColor</a> <i>c</i>)</h3><p>Convenience function for specifying the clearing color to OpenGL. Calls glClearColor (in RGBA mode) or glClearIndex (in color-index mode) with the color <i>c</i>. Applies to this widgets GL context.</p>
<p>See also <a href="qglwidget.html#qglColor">qglColor</a>(), <a href="qglcontext.html#currentContext">QGLContext.currentContext</a>(), and <a href="qcolor.html">QColor</a>.</p>
<h3 class="fn"><a name="qglColor" />QGLWidget.qglColor (<i>self</i>, <a href="qcolor.html">QColor</a> <i>c</i>)</h3><p>Convenience function for specifying a drawing color to OpenGL. Calls glColor4 (in RGBA mode) or glIndex (in color-index mode) with the color <i>c</i>. Applies to this widgets GL context.</p>
<p>See also <a href="qglwidget.html#qglClearColor">qglClearColor</a>(), <a href="qglcontext.html#currentContext">QGLContext.currentContext</a>(), and <a href="qcolor.html">QColor</a>.</p>
<h3 class="fn"><a name="renderPixmap" /><a href="qpixmap.html">QPixmap</a> QGLWidget.renderPixmap (<i>self</i>, int <i>w</i> = 0, int <i>h</i> = 0, bool <i>useContext</i> = False)</h3><p>Renders the current scene on a pixmap and returns the pixmap.</p>
<p>You can use this method on both visible and invisible QGLWidgets.</p>
<p>This method will create a pixmap and a temporary <a href="qglcontext.html">QGLContext</a> to render on the pixmap. It will then call <a href="qglwidget.html#initializeGL">initializeGL</a>(), <a href="qglwidget.html#resizeGL">resizeGL</a>(), and <a href="qglwidget.html#paintGL">paintGL</a>() on this context. Finally, the widget's original GL context is restored.</p>
<p>The size of the pixmap will be <i>w</i> pixels wide and <i>h</i> pixels high unless one of these parameters is 0 (the default), in which case the pixmap will have the same size as the widget.</p>
<p>If <i>useContext</i> is true, this method will try to be more efficient by using the existing GL context to render the pixmap. The default is false. Only use true if you understand the risks. Note that under Windows a temporary context has to be created and usage of the <i>useContext</i> parameter is not supported.</p>
<p>Overlays are not rendered onto the pixmap.</p>
<p>If the GL rendering context and the desktop have different bit depths, the result will most likely look surprising.</p>
<p>Note that the creation of display lists, modifications of the view frustum etc. should be done from within <a href="qglwidget.html#initializeGL">initializeGL</a>(). If this is not done, the temporary <a href="qglcontext.html">QGLContext</a> will not be initialized properly, and the rendered pixmap may be incomplete/corrupted.</p>
<h3 class="fn"><a name="renderText" />QGLWidget.renderText (<i>self</i>, int <i>x</i>, int <i>y</i>, <a href="qstring.html">QString</a> <i>str</i>, <a href="qfont.html">QFont</a> <i>fnt</i> = QFont(), int <i>listBase</i> = 2000)</h3><h3 class="fn"><a name="renderText-2" />QGLWidget.renderText (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>z</i>, <a href="qstring.html">QString</a> <i>str</i>, <a href="qfont.html">QFont</a> <i>fnt</i> = QFont(), int <i>listBase</i> = 2000)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p><i>x</i>, <i>y</i> and <i>z</i> are specified in scene or object coordinates relative to the currently set projection and model matrices. This can be useful if you want to annotate models with text labels and have the labels move with the model as it is rotated etc.</p>
<h3 class="fn"><a name="resizeEvent" />QGLWidget.resizeEvent (<i>self</i>, <a href="qresizeevent.html">QResizeEvent</a>)</h3><p>Handles resize events that are passed in the <i>event</i> parameter. Calls the virtual function <a href="qglwidget.html#resizeGL">resizeGL</a>().</p>
<p>Reimplemented from <a href="qwidget.html#resizeEvent">QWidget</a>.</p>
<h3 class="fn"><a name="resizeGL" />QGLWidget.resizeGL (<i>self</i>, int <i>w</i>, int <i>h</i>)</h3><p>This virtual function is called whenever the widget has been resized. The new size is passed in <i>width</i> and <i>height</i>. Reimplement it in a subclass.</p>
<p>There is no need to call <a href="qglwidget.html#makeCurrent">makeCurrent</a>() because this has already been done when this function is called.</p>
<h3 class="fn"><a name="resizeOverlayGL" />QGLWidget.resizeOverlayGL (<i>self</i>, int <i>w</i>, int <i>h</i>)</h3><p>This virtual function is used in the same manner as <a href="qglwidget.html#paintGL">paintGL</a>() except that it operates on the widget's overlay context instead of the widget's main context. This means that resizeOverlayGL() is called whenever the widget has been resized. The new size is passed in <i>width</i> and <i>height</i>. Reimplement it in a subclass.</p>
<p>There is no need to call <a href="qglwidget.html#makeOverlayCurrent">makeOverlayCurrent</a>() because this has already been done when this function is called.</p>
<h3 class="fn"><a name="setAutoBufferSwap" />QGLWidget.setAutoBufferSwap (<i>self</i>, bool <i>on</i>)</h3><p>If <i>on</i> is true automatic GL buffer swapping is switched on; otherwise it is switched off.</p>
<p>If <i>on</i> is true and the widget is using a double-buffered format, the background and foreground GL buffers will automatically be swapped after each <a href="qglwidget.html#paintGL">paintGL</a>() call.</p>
<p>The buffer auto-swapping is on by default.</p>
<p>See also <a href="qglwidget.html#autoBufferSwap">autoBufferSwap</a>(), <a href="qglwidget.html#doubleBuffer">doubleBuffer</a>(), and <a href="qglwidget.html#swapBuffers">swapBuffers</a>().</p>
<h3 class="fn"><a name="setColormap" />QGLWidget.setColormap (<i>self</i>, <a href="qglcolormap.html">QGLColormap</a> <i>map</i>)</h3><p>Set the colormap for this widget to <i>cmap</i>. Usually it is only top-level widgets that can have colormaps installed.</p>
<p>See also <a href="qglwidget.html#colormap">colormap</a>().</p>
<h3 class="fn"><a name="setContext" />QGLWidget.setContext (<i>self</i>, <a href="qglcontext.html">QGLContext</a> <i>context</i>, <a href="qglcontext.html">QGLContext</a> <i>shareContext</i> = None, bool <i>deleteOldContext</i> = True)</h3><h3 class="fn"><a name="setFormat" />QGLWidget.setFormat (<i>self</i>, <a href="qglformat.html">QGLFormat</a> <i>format</i>)</h3><h3 class="fn"><a name="setMouseTracking" />QGLWidget.setMouseTracking (<i>self</i>, bool <i>enable</i>)</h3><p>If <i>enable</i> is true then mouse tracking is enabled; otherwise it is disabled.</p>
<h3 class="fn"><a name="swapBuffers" />QGLWidget.swapBuffers (<i>self</i>)</h3><p>Swaps the screen contents with an off-screen buffer. This only works if the widget's format specifies double buffer mode.</p>
<p>Normally, there is no need to explicitly call this function because it is done automatically after each widget repaint, i.e. each time after <a href="qglwidget.html#paintGL">paintGL</a>() has been executed.</p>
<p>See also <a href="qglwidget.html#doubleBuffer">doubleBuffer</a>(), <a href="qglwidget.html#setAutoBufferSwap">setAutoBufferSwap</a>(), and <a href="qglformat.html#setDoubleBuffer">QGLFormat.setDoubleBuffer</a>().</p>
<h3 class="fn"><a name="updateGL" />QGLWidget.updateGL (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void updateGL()</tt>.</p><p>Updates the widget by calling <a href="qglwidget.html#glDraw">glDraw</a>().</p>
<h3 class="fn"><a name="updateOverlayGL" />QGLWidget.updateOverlayGL (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void updateOverlayGL()</tt>.</p><p>Updates the widget's overlay (if any). Will cause the virtual function <a href="qglwidget.html#paintOverlayGL">paintOverlayGL</a>() to be executed.</p>
<p>The widget's rendering context will become the current context and <a href="qglwidget.html#initializeGL">initializeGL</a>() will be called if it hasn't already been called.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|