<!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:1579 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Continuing Development</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 Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped 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>Continuing Development</h1> [ <a href="motif-walkthrough-9.html">Previous: Replacing the Print Dialog</a> ] [ <a href="motif-walkthrough.html">Home</a> ] <p> We have not quite finished with the migration to TQt, even though our project does not use <a href="motif-extension.html#Motif">Motif</a> any more. TQt provides many useful features that we can begin using immediately. Some of the most interesting ones are presented below as a guide for where to start extending your existing projects. <p> <h2> Using Unicode </h2> <a name="1"></a><p> Support for <a href="i18n.html">internationalization</a> is very easy with TQt. Using <a href="ntqstring.html">TQString</a> instead of <tt>char*</tt> for storing text gives us support for most of the written languages around the world. Our <tt>Page</tt> and <tt>Options</tt> structs look much simpler now. <p> <p> <pre></pre> <p> <pre></pre> <p> All functions that use the <tt>Page</tt> and <tt>Options</tt> structs need to be updated to use TQString properly. Since TQString is also an <a href="shclass.html#implicitly-shared">implicitly shared</a> class, we no longer have to do any memory management with our strings. We can remove all occurences of the <a href="ntqcstring.html#qstrdup">tqstrdup</a>() function, and we never need to use <em>new</em> or <em>delete</em> when done with a string. TQString will allocate and delete data when needed. <p> Here are the <tt>MainWindow::fileOpen()</tt> and <tt>MainWindow::pageChange()</tt> functions from <tt>mainwindow.ui.h</tt>. Notice that the code no longer uses <em>delete</em> or <a href="ntqcstring.html#qstrdup">tqstrdup</a>() when storing text. <p> <p> <pre></pre> <p> <pre> ... </pre> <p> <pre></pre> <p> Almost all of the functions in our application are affected by this change. In most cases, we end up removing more code than we are adding. To keep the size of this walkthrough reasonable, we've only shown a small portion of the required changes, since the changes are very similar to those shown above. <p> <h2> Writing Platform-Independent Code </h2> <a name="2"></a><p> TQt provides many <a href="io.html">input and output</a> classes. We can use these in <tt>MainWindow::readDB()</tt> and <tt>MainWindow::saveDB()</tt>. Currently, these functions use functions only found on UNIX machines. Using <a href="ntqfile.html">TQFile</a> and <a href="ntqtextstream.html">TQTextStream</a> removes this dependency on UNIX, and we can begin building and testing our application on Microsoft Windows and Apple Mac OS X. <p> The platform-independent versions of the <tt>MainWindow::readDB()</tt> and <tt>MainWindow::saveDB()</tt> functions can be found in the <tt>io.cpp</tt> file. <p> <h2> Designing a Modern User Interface </h2> <a name="3"></a><p> Since we used the <em>TQt Designer</em> to design the <em>Main Window</em> widget, we can extend the interface easily. We can use some of the more advanced features of <a href="ntqmainwindow.html">TQMainWindow</a>, which includes dockable toolbars. Adding these is simple with the <em>TQt Designer</em>. The final version of our project includes a toolbar, which provides quick access to the <em>Open</em>, <em>Save</em>, <em>Print</em>, <em>New Page</em> and <em>Delete to Trash</em> actions. <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 short period of time. As our project expands to other platforms, we could add menus and dialogs that allow us synchronize todo lists between a normal desktop computer and a handheld device running with TQt/Embedded. <p> [ <a href="motif-walkthrough-9.html">Previous: Replacing the Print Dialog</a> ] [ <a href="motif-walkthrough.html">Home</a> ] <p> <!-- eof --> <p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 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>