project does not use <ahref="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>
<aname="1"></a><p> Support for <ahref="i18n.html">internationalization</a> is very easy
with TQt. Using <ahref="qstring.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 <ahref="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 <ahref="qcstring.html#qstrdup">qstrdup</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 <ahref="qcstring.html#qstrdup">qstrdup</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 retquired changes, since the changes are
very similar to those shown above.
<p><h2> Writing Platform-Independent Code
</h2>
<aname="2"></a><p> TQt provides many <ahref="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 <ahref="qfile.html">TQFile</a> and <ahref="qtextstream.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>
<aname="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 <ahref="qmainwindow.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 tquick
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> [ <ahref="motif-walkthrough-9.html">Previous: Replacing the Print Dialog</a> ]