You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/html/motif-walkthrough.html

151 lines
7.5 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/extensions/motif/doc/walkthrough.doc:2 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQt Motif Extension - A Migration Walkthrough</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQt Motif Extension - A Migration Walkthrough</h1>
[ <a href="motif-walkthrough-1.html">Next: Getting Started</a> ]
<p> This walkthrough covers a complete migration of a <a href="motif-extension.html#Motif">Motif</a> based program
to the TQt toolkit using the <em>TQt Motif Extension</em>.
<p> It is rarely practical for a large project with hundreds of thousands
or even millions of lines of code to be migrated all at once; such an
endeavor would require too many development resources and would incur
significant risks. Every line of code would have to be rewritten,
every user interface redesigned, and quality assurance tests and
procedures all rewritten. The <em>TQt Motif Extension</em> provides a
complete and working solution for incremental migration that can be
paced to suit each individual project and the available resources. The
user interface and related code can be migrated in steps while the
rest of the project need not be changed at all.
<p> This walkthrough is intended for programmers who will be migrating an
existing Motif based project to the TQt toolkit. We assume that they
have experience with C/C++ and Xt/Motif. Some experience with the TQt
toolkit is also necessary. For developers completely new to TQt we
recommend following the learning plan outlined in <a href="how-to-learn-qt.html">How to Learn TQt</a>; or to go on a TQt
training course. (See <a href="http://www.trolltech.com">http://www.trolltech.com</a> for
details of training courses.)
<p> <h2> Goals for the Walkthrough
</h2>
<a name="1"></a><p> The goal of this walkthrough is to provide the reader with enough
knowledge to migrate Motif applications to the TQt toolkit. We will do
this by example: We will convert a real-world Motif based program
step-by-step. This walkthrough will discuss both techniques and their
rationales throughout the process. This walkthrough is broken down
into individual chapters which cover a specific topic:
<p> <ul>
<li> Chapter 1: <a href="motif-walkthrough-1.html">Getting Started</a>
<li> Chapter 2: <a href="motif-walkthrough-2.html">Preparing to Migrate the User Interface</a>
<li> Chapter 3: <a href="motif-walkthrough-3.html">Using TQt Standard Dialogs</a>
<li> Chapter 4: <a href="motif-walkthrough-4.html">Using Custom TQDialogs</a>
<li> Chapter 5: <a href="motif-walkthrough-5.html">Using Existing Dialogs with TQMotifDialog</a>
<li> Chapter 6: <a href="motif-walkthrough-6.html">Using TQt Main Window Classes</a>
<li> Chapter 7: <a href="motif-walkthrough-7.html">Refactoring Existing Code</a>
<li> Chapter 8: <a href="motif-walkthrough-8.html">Replacing the View Widget</a>
<li> Chapter 9: <a href="motif-walkthrough-9.html">Replacing the Print Dialog</a>
<li> Chapter 10: <a href="motif-walkthrough-10.html">Continuing Development</a>
</ul>
<p> We will use the <em>todo</em> demo program included with the Motif 2.x
distribution as our migration project. This walkthrough contains
references to the source code, which is included in the <tt>extensions/motif/examples/walkthrough</tt> subdirectory.
<p> <h2> Preretquisites
</h2>
<a name="2"></a><p> Before we can start using the <em>TQt Motif Extension</em>, we must satisfy
these requirements:
<p> <ol type=1>
<li> We are using the X11R6.x and Motif 2.x libraries.
<li> The project is compilable by a C++ compiler.
<li> We have built and installed the <em>TQt Motif Extension</em>.
<li> We have built and linked the project with the TQt toolkit and the <em>TQt Motif Extension</em>
</ol>
<p> <h3> X11R6.x and Motif 2.x Libraries
</h3>
<a name="2-1"></a><p> The mechanisms used by the <em>TQt Motif Extension</em> require development
headers and libraries from the X11R6 release and the Motif 2.0
release. Newer versions of these can also be used.
<p> <h3> C++ Compiler
</h3>
<a name="2-2"></a><p> Since TQt is a C++ toolkit, all new code will be written in C++. In
order for existing code to coexist with new code, a C++ compiler must
be able to compile the existing code.
<p> It is possible to keep existing code and new code separate, and only
convert or rewrite existing code as needed. This is a normal part
of the migration process, and does not need to be done before the
migration process begins. This is the most common scenario, and we
will demonstrate it by migrating existing C code to C++ as needed in
this walkthrough.
<p> <h3> Build and Install the TQt Motif Extension
</h3>
<a name="2-3"></a><p> The <em>TQt Motif Extension</em> is not built and installed along with the
TQt toolkit. The extension resides in the <tt>extensions/motif</tt>
subdirectory. Run <em>make</em> in this directory to build the extension
and the examples. Once the extension has been built, run <em>make install</em>.
<p> <pre>
$ cd extensions/motif
$ make
$ make install
</pre>
<p> The <em>TQt Motif Extension</em> is now installed and ready to use.
<p> <h3> Build and Link the Project with the TQt Toolkit and the TQt Motif Extension
</h3>
<a name="2-4"></a><p> For simplicity, we use <em>qmake</em> to create the <tt>Makefile</tt>. The <tt>-project</tt> option causes <em>qmake</em> to automatically generate a project
file. After <em>qmake -project</em> has generated our project file, we
run <em>qmake</em> again to generate a <tt>Makefile</tt>. Now, we can just run <em>make</em> to build our project.
<p> <pre>
$ qmake -project
$ qmake
$ make
</pre>
<p> Everything builds correctly, but fails to link because we don't link
with the Motif library. We tell <em>qmake</em> to do this by adding the <tt>-lXm</tt> to the <tt>LIBS</tt> variable in our project file. Since we are
planning to use the <em>TQt Motif Extension</em> in this project as well,
we should also add <tt>-lqmotif</tt> to the list of libraries.
<p> <pre>
LIBS += -lXm -lqmotif
</pre>
<p> Now we regenerate our <tt>Makefile</tt> by running <tt>qmake</tt> again, and
rebuild using <tt>make</tt>. This time, our project successfully links, and
the application runs as expected.
<p> We are now ready to start using the <em>TQt Motif Extension</em>.
<p> [ <a href="motif-walkthrough-1.html">Next: Getting Started</a> ]
<p>
<!-- eof -->
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>