source: trunk/doc/html/opengl-overlay-x11-example.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 5.4 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/examples/opengl/overlay_x11/overlay_x11.doc:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>OpenGL Overlay X11 Example</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>OpenGL Overlay X11 Example</h1>
33
34
35<p>
36<b>Warning:</b> From version 5.0 onwards, the Qt OpenGL Extension includes
37direct support for use of OpenGL overlays. For many uses of overlays,
38this makes the technique described below redundant. See the <a href="opengl-overlay-example.html">overlay</a> example program. The
39following is a discussion on how to use non-QGL widgets in overlay
40planes.
41<p> Overlayrubber: An example program showing how to use Qt and Qt OpenGL
42Extension with X11 overlay visuals.
43<p> See <tt>$QTDIR/examples/opengl/overlay_x11</tt> for the source code.
44<p> Background information for this example can be found in the
45information on <a href="opengl-x11-overlays.html">overlays</a>.
46<p> The example program has three main parts:
47<p> <ol type=1>
48<li> <em>GearWidget</em> - a normal, simple <a href="qglwidget.html">QGLWidget</a>. This renders the usual
49gears. It has been modified to print a debug message every time it
50redraws (renders) itself. Thus, you can easily confirm that drawing in
51the overlay plane does not cause redrawings in the main plane where
52the QGLWidget resides.
53<p> <li> <em>RubberbandWidget</em> - Very simple standard (non-GL) Qt widget that
54implements rubberband drawing. Designed for use in an overlay plane.
55It takes the plane's transparent color as a constructor argument and
56uses that for its background color. Thus, the widget itself will be
57invisible, only the rubberbands it draws will be visible.
58<p> <li> <em>main.cpp</em> Creates a GearWidget and a Rubberbandwidget and puts the
59latter on top of the former. Contains a routine that checks that the
60default visual is in an overlay plane, and returns the transparent
61color of that plane.
62</ol>
63<p> <h2> Running the Example
64</h2>
65<a name="1"></a><p> Start the <tt>overlayrubber</tt> executable. Click and drag with the left
66mouse button to see rubberband drawing. Observe that the <a href="qglwidget.html">QGLWidget</a>
67does not redraw itself (no redraw debug messages are output), and yet
68the image is not destroyed. Marvel at the coolness of X11 overlays!
69<p> <h2> Using this technique in a real application
70</h2>
71<a name="2"></a><p> For clarity, this example program has been kept very simple. Here are
72some hints for real application usage:
73<p> <ul>
74<p> <li> <em>All normal widgets are in the overlay plane.</em> This means that you
75can put all kinds of Qt widgets (your own or standard Qt widgets) on
76top of the OpenGL image (widget), e.g. pushbuttons etc., and they can
77be moved, resized, or removed without destroying the OpenGL image.
78<p> <li> <em>Using with geometry management.</em> The <a href="qlayout.html">QLayout</a> classes don't permit
79putting one widget (the overlay) on top of another (the OpenGL
80widget); that would defy the whole purpose of the automatic layout.
81The solution is to add just one of them to the QLayout object. Have it
82keep a pointer to the other (i.e. the <a href="qglwidget.html">QGLWidget</a> knows about its
83overlay widget or vice versa). Implement the resizeEvent() method of
84the widget you put in the layout, and make it call setGeometry() on
85the other widget with its own geometry as parameters, thus keeping the
86two widgets' geometries synchronized.
87<p> <li> <em>Using together with <a href="qpalette.html">QPalette</a> and <a href="qcolorgroup.html">QColorGroup</a>.</em> Instead of the
88simplistic setBackgroundColor( transparentColor ), you can
89use Qt's QPalette system to make your overlay widgets use
90transparent color for what you want. This way, the normal Qt widgets
91can be used as overlays for fancy effects. Just create a palette for
92them with the transparent color for the relevant color roles, e.g.
93Background and Base, in the Normal and/or Active modes. This way, you
94can create see-through QPushButtons etc.
95</ul>
96<p> <p>See also <a href="opengl-examples.html">OpenGL Examples</a>.
97
98<!-- eof -->
99<p><address><hr><div align=center>
100<table width=100% cellspacing=0 border=0><tr>
101<td>Copyright &copy; 2007
102<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
103<td align=right><div align=right>Qt 3.3.8</div>
104</table></div></address></body>
105</html>
Note: See TracBrowser for help on using the repository browser.