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

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

reference documentation added

File size: 5.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:1579 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>Continuing Development</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>Continuing Development</h1>
33
34
35
36[ <a href="motif-walkthrough-9.html">Previous: Replacing the Print Dialog</a> ]
37[ <a href="motif-walkthrough.html">Home</a> ]
38<p> We have not quite finished with the migration to Qt, even though our
39project does not use <a href="motif-extension.html#Motif">Motif</a> any more. Qt provides many useful features
40that we can begin using immediately. Some of the most interesting
41ones are presented below as a guide for where to start extending your
42existing projects.
43<p> <h2> Using Unicode
44</h2>
45<a name="1"></a><p> Support for <a href="i18n.html">internationalization</a> is very easy
46with Qt. Using <a href="qstring.html">QString</a> instead of <tt>char*</tt> for storing text gives
47us support for most of the written languages around the world. Our <tt>Page</tt> and <tt>Options</tt> structs look much simpler now.
48<p>
49
50<p> <pre></pre>
51<p> <pre></pre>
52<p> All functions that use the <tt>Page</tt> and <tt>Options</tt> structs need to be
53updated to use QString properly. Since QString is also an <a href="shclass.html#implicitly-shared">implicitly shared</a> class, we no longer have to do any memory management with our
54strings. We can remove all occurences of the <a href="qcstring.html#qstrdup">qstrdup</a>() function,
55and we never need to use <em>new</em> or <em>delete</em> when done with a string.
56QString will allocate and delete data when needed.
57<p> Here are the <tt>MainWindow::fileOpen()</tt> and <tt>MainWindow::pageChange()</tt>
58functions from <tt>mainwindow.ui.h</tt>. Notice that the code no longer
59uses <em>delete</em> or <a href="qcstring.html#qstrdup">qstrdup</a>() when storing text.
60<p>
61
62<p> <pre></pre>
63<p> <pre>
64 ...
65</pre>
66
67<p> <pre></pre>
68<p> Almost all of the functions in our application are affected by this
69change. In most cases, we end up removing more code than we are
70adding. To keep the size of this walkthrough reasonable, we've only
71shown a small portion of the required changes, since the changes are
72very similar to those shown above.
73<p> <h2> Writing Platform-Independent Code
74</h2>
75<a name="2"></a><p> Qt provides many <a href="io.html">input and output</a> classes. We
76can use these in <tt>MainWindow::readDB()</tt> and <tt>MainWindow::saveDB()</tt>.
77Currently, these functions use functions only found on UNIX machines.
78Using <a href="qfile.html">QFile</a> and <a href="qtextstream.html">QTextStream</a> removes this dependency on UNIX, and we can
79begin building and testing our application on Microsoft Windows and
80Apple Mac OS X.
81<p> The platform-independent versions of the <tt>MainWindow::readDB()</tt> and
82<tt>MainWindow::saveDB()</tt> functions can be found in the <tt>io.cpp</tt> file.
83<p> <h2> Designing a Modern User Interface
84</h2>
85<a name="3"></a><p> Since we used the <em>Qt Designer</em> to design the <em>Main Window</em>
86widget, we can extend the interface easily. We can use some of the
87more advanced features of <a href="qmainwindow.html">QMainWindow</a>, which includes dockable
88toolbars. Adding these is simple with the <em>Qt Designer</em>. The
89final version of our project includes a toolbar, which provides quick
90access to the <em>Open</em>, <em>Save</em>, <em>Print</em>, <em>New Page</em> and <em>Delete to Trash</em> actions.
91<p> The possibilities are endless. An <em>Edit</em> menu, with the common <em>Cut</em>, <em>Copy</em> and <em>Paste</em> actions, could be added in a relatively
92short period of time. As our project expands to other platforms, we
93could add menus and dialogs that allow us synchronize todo lists
94between a normal desktop computer and a handheld device running with
95Qt/Embedded.
96<p> [ <a href="motif-walkthrough-9.html">Previous: Replacing the Print Dialog</a> ]
97[ <a href="motif-walkthrough.html">Home</a> ]
98<p>
99<!-- eof -->
100<p><address><hr><div align=center>
101<table width=100% cellspacing=0 border=0><tr>
102<td>Copyright &copy; 2007
103<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
104<td align=right><div align=right>Qt 3.3.8</div>
105</table></div></address></body>
106</html>
Note: See TracBrowser for help on using the repository browser.