source: trunk/doc/html/motif-walkthrough-1.html@ 208

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

reference documentation added

File size: 4.3 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/extensions/motif/doc/walkthrough.doc:147 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>Getting Started</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>Getting Started</h1>
33
34
35
36[ <a href="motif-walkthrough.html">Home</a> ]
37[ <a href="motif-walkthrough-2.html">Next: Preparing to Migrate the User Interface</a> ]
38<p> <h2> Starting with <a href="qmotif.html">QMotif</a> and <a href="qapplication.html">QApplication</a>
39</h2>
40<a name="1"></a><p> To be able to use Qt, we need to create a QApplication object. The
41QApplication class controls all the event delivery and display
42management for all other Qt objects and widgets. We need to use the
43QMotif class from the <em>Qt <a href="motif-extension.html#Motif">Motif</a> Extension</em> to allow QApplication
44and the <tt>XtAppContext</tt> to coexist.
45<p> The QApplication object must be created in the <tt>main()</tt> function.
46We will need to modify <tt>todo.c</tt> to compile with a C++ compiler, so we
47rename <tt>todo.c</tt> to <tt>todo.cpp</tt>.
48<p> Next, we add the appropriate includes for the QMotif and QApplication
49classes.
50<p>
51
52<pre></pre>
53<p> Next, we create the QMotif and QApplication objects. We create QMotif
54with a foreign <tt>XtAppContext</tt>, and we create QApplication with a
55foreign <tt>Display</tt>.
56<p> <pre></pre>
57<p> The next change is not yet necessary, but it is included to show that
58the <em>Qt Motif Extension</em> provides a complete integration.
59Normally, a Motif based program would use the <tt>XtAppMainLoop()</tt>
60function to run the application's event loop. This is still possible,
61but since we are migrating to the Qt toolkit, we prefer to use the
62<a href="qapplication.html#exec">QApplication::exec</a>() function for running the event loop.
63<p> <pre></pre>
64<p> Since we renamed <tt>todo.c</tt> to <tt>todo.cpp</tt>, we must change the
65project file and rerun <em>qmake</em> to regenerate our <tt>Makefile</tt>. When we
66build our project, there are compile and link errors: we will fix
67these in the following section.
68<p> <h2> Migrating to C++
69</h2>
70<a name="2"></a><p> We need to convert the code in this file to proper C++ code.
71Fortunately, the changes are not too large. Most files included from
72existing C projects are not C++ compatible, so we make them compatible
73by wrapping them in an <tt>extern "C"</tt> block.
74<p>
75
76<p> <pre></pre>
77<p> Global C functions that are forward declared must also be wrapped into
78an <tt>extern "C"</tt> block.
79<p> <pre></pre>
80<p> The <tt>manageCB()</tt> function needs to be converted to proper C++.
81<p> <pre></pre>
82<p> And we need to fix two invalid casts. One is in the <tt>Save()</tt> function.
83<p> <pre></pre>
84<p> The other invalid cast is in the <tt>Open()</tt> function.
85<p> <pre></pre>
86<p> After these changes, the project compiles and links, and the
87application runs and operates correctly.
88<p> [ <a href="motif-walkthrough.html">Home</a> ]
89[ <a href="motif-walkthrough-2.html">Next: Preparing to Migrate the User Interface</a> ]
90<p>
91<!-- eof -->
92<p><address><hr><div align=center>
93<table width=100% cellspacing=0 border=0><tr>
94<td>Copyright &copy; 2007
95<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
96<td align=right><div align=right>Qt 3.3.8</div>
97</table></div></address></body>
98</html>
Note: See TracBrowser for help on using the repository browser.