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:2 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>Qt Motif Extension - A Migration Walkthrough</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { 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 Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main 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 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>Qt Motif Extension - A Migration Walkthrough</h1>
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | [ <a href="motif-walkthrough-1.html">Next: Getting Started</a> ]
|
---|
37 | <p> This walkthrough covers a complete migration of a <a href="motif-extension.html#Motif">Motif</a> based program
|
---|
38 | to the Qt toolkit using the <em>Qt Motif Extension</em>.
|
---|
39 | <p> It is rarely practical for a large project with hundreds of thousands
|
---|
40 | or even millions of lines of code to be migrated all at once; such an
|
---|
41 | endeavor would require too many development resources and would incur
|
---|
42 | significant risks. Every line of code would have to be rewritten,
|
---|
43 | every user interface redesigned, and quality assurance tests and
|
---|
44 | procedures all rewritten. The <em>Qt Motif Extension</em> provides a
|
---|
45 | complete and working solution for incremental migration that can be
|
---|
46 | paced to suit each individual project and the available resources. The
|
---|
47 | user interface and related code can be migrated in steps while the
|
---|
48 | rest of the project need not be changed at all.
|
---|
49 | <p> This walkthrough is intended for programmers who will be migrating an
|
---|
50 | existing Motif based project to the Qt toolkit. We assume that they
|
---|
51 | have experience with C/C++ and Xt/Motif. Some experience with the Qt
|
---|
52 | toolkit is also necessary. For developers completely new to Qt we
|
---|
53 | recommend following the learning plan outlined in <a href="how-to-learn-qt.html">How to Learn Qt</a>; or to go on a Qt
|
---|
54 | training course. (See <a href="http://www.trolltech.com">http://www.trolltech.com</a> for
|
---|
55 | details of training courses.)
|
---|
56 | <p> <h2> Goals for the Walkthrough
|
---|
57 | </h2>
|
---|
58 | <a name="1"></a><p> The goal of this walkthrough is to provide the reader with enough
|
---|
59 | knowledge to migrate Motif applications to the Qt toolkit. We will do
|
---|
60 | this by example: We will convert a real-world Motif based program
|
---|
61 | step-by-step. This walkthrough will discuss both techniques and their
|
---|
62 | rationales throughout the process. This walkthrough is broken down
|
---|
63 | into individual chapters which cover a specific topic:
|
---|
64 | <p> <ul>
|
---|
65 | <li> Chapter 1: <a href="motif-walkthrough-1.html">Getting Started</a>
|
---|
66 | <li> Chapter 2: <a href="motif-walkthrough-2.html">Preparing to Migrate the User Interface</a>
|
---|
67 | <li> Chapter 3: <a href="motif-walkthrough-3.html">Using Qt Standard Dialogs</a>
|
---|
68 | <li> Chapter 4: <a href="motif-walkthrough-4.html">Using Custom QDialogs</a>
|
---|
69 | <li> Chapter 5: <a href="motif-walkthrough-5.html">Using Existing Dialogs with QMotifDialog</a>
|
---|
70 | <li> Chapter 6: <a href="motif-walkthrough-6.html">Using Qt Main Window Classes</a>
|
---|
71 | <li> Chapter 7: <a href="motif-walkthrough-7.html">Refactoring Existing Code</a>
|
---|
72 | <li> Chapter 8: <a href="motif-walkthrough-8.html">Replacing the View Widget</a>
|
---|
73 | <li> Chapter 9: <a href="motif-walkthrough-9.html">Replacing the Print Dialog</a>
|
---|
74 | <li> Chapter 10: <a href="motif-walkthrough-10.html">Continuing Development</a>
|
---|
75 | </ul>
|
---|
76 | <p> We will use the <em>todo</em> demo program included with the Motif 2.x
|
---|
77 | distribution as our migration project. This walkthrough contains
|
---|
78 | references to the source code, which is included in the <tt>extensions/motif/examples/walkthrough</tt> subdirectory.
|
---|
79 | <p> <h2> Prerequisites
|
---|
80 | </h2>
|
---|
81 | <a name="2"></a><p> Before we can start using the <em>Qt Motif Extension</em>, we must satisfy
|
---|
82 | these requirements:
|
---|
83 | <p> <ol type=1>
|
---|
84 | <li> We are using the X11R6.x and Motif 2.x libraries.
|
---|
85 | <li> The project is compilable by a C++ compiler.
|
---|
86 | <li> We have built and installed the <em>Qt Motif Extension</em>.
|
---|
87 | <li> We have built and linked the project with the Qt toolkit and the <em>Qt Motif Extension</em>
|
---|
88 | </ol>
|
---|
89 | <p> <h3> X11R6.x and Motif 2.x Libraries
|
---|
90 | </h3>
|
---|
91 | <a name="2-1"></a><p> The mechanisms used by the <em>Qt Motif Extension</em> require development
|
---|
92 | headers and libraries from the X11R6 release and the Motif 2.0
|
---|
93 | release. Newer versions of these can also be used.
|
---|
94 | <p> <h3> C++ Compiler
|
---|
95 | </h3>
|
---|
96 | <a name="2-2"></a><p> Since Qt is a C++ toolkit, all new code will be written in C++. In
|
---|
97 | order for existing code to coexist with new code, a C++ compiler must
|
---|
98 | be able to compile the existing code.
|
---|
99 | <p> It is possible to keep existing code and new code separate, and only
|
---|
100 | convert or rewrite existing code as needed. This is a normal part
|
---|
101 | of the migration process, and does not need to be done before the
|
---|
102 | migration process begins. This is the most common scenario, and we
|
---|
103 | will demonstrate it by migrating existing C code to C++ as needed in
|
---|
104 | this walkthrough.
|
---|
105 | <p> <h3> Build and Install the Qt Motif Extension
|
---|
106 | </h3>
|
---|
107 | <a name="2-3"></a><p> The <em>Qt Motif Extension</em> is not built and installed along with the
|
---|
108 | Qt toolkit. The extension resides in the <tt>extensions/motif</tt>
|
---|
109 | subdirectory. Run <em>make</em> in this directory to build the extension
|
---|
110 | and the examples. Once the extension has been built, run <em>make install</em>.
|
---|
111 | <p> <pre>
|
---|
112 | $ cd extensions/motif
|
---|
113 | $ make
|
---|
114 | $ make install
|
---|
115 | </pre>
|
---|
116 |
|
---|
117 | <p> The <em>Qt Motif Extension</em> is now installed and ready to use.
|
---|
118 | <p> <h3> Build and Link the Project with the Qt Toolkit and the Qt Motif Extension
|
---|
119 | </h3>
|
---|
120 | <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
|
---|
121 | file. After <em>qmake -project</em> has generated our project file, we
|
---|
122 | run <em>qmake</em> again to generate a <tt>Makefile</tt>. Now, we can just run <em>make</em> to build our project.
|
---|
123 | <p> <pre>
|
---|
124 | $ qmake -project
|
---|
125 | $ qmake
|
---|
126 | $ make
|
---|
127 | </pre>
|
---|
128 |
|
---|
129 | <p> Everything builds correctly, but fails to link because we don't link
|
---|
130 | 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
|
---|
131 | planning to use the <em>Qt Motif Extension</em> in this project as well,
|
---|
132 | we should also add <tt>-lqmotif</tt> to the list of libraries.
|
---|
133 | <p> <pre>
|
---|
134 | LIBS += -lXm -lqmotif
|
---|
135 | </pre>
|
---|
136 |
|
---|
137 | <p> Now we regenerate our <tt>Makefile</tt> by running <tt>qmake</tt> again, and
|
---|
138 | rebuild using <tt>make</tt>. This time, our project successfully links, and
|
---|
139 | the application runs as expected.
|
---|
140 | <p> We are now ready to start using the <em>Qt Motif Extension</em>.
|
---|
141 | <p> [ <a href="motif-walkthrough-1.html">Next: Getting Started</a> ]
|
---|
142 | <p>
|
---|
143 | <!-- eof -->
|
---|
144 | <p><address><hr><div align=center>
|
---|
145 | <table width=100% cellspacing=0 border=0><tr>
|
---|
146 | <td>Copyright © 2007
|
---|
147 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
148 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
149 | </table></div></address></body>
|
---|
150 | </html>
|
---|