Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

Continuing Development

[ Previous: Replacing the Print Dialog ] [ Home ]

We have not quite finished with the migration to TQt, even though our project does not use Motif 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.

Using Unicode

Support for internationalization is very easy with TQt. Using TQString instead of char* for storing text gives us support for most of the written languages around the world. Our Page and Options structs look much simpler now.



All functions that use the Page and Options structs need to be updated to use TQString properly. Since TQString is also an implicitly shared class, we no longer have to do any memory management with our strings. We can remove all occurences of the tqstrdup() function, and we never need to use new or delete when done with a string. TQString will allocate and delete data when needed.

Here are the MainWindow::fileOpen() and MainWindow::pageChange() functions from mainwindow.ui.h. Notice that the code no longer uses delete or tqstrdup() when storing text.


    ...


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.

Writing Platform-Independent Code

TQt provides many input and output classes. We can use these in MainWindow::readDB() and MainWindow::saveDB(). Currently, these functions use functions only found on UNIX machines. Using TQFile and TQTextStream removes this dependency on UNIX, and we can begin building and testing our application on Microsoft Windows and Apple Mac OS X.

The platform-independent versions of the MainWindow::readDB() and MainWindow::saveDB() functions can be found in the io.cpp file.

Designing a Modern User Interface

Since we used the TQt Designer to design the Main Window widget, we can extend the interface easily. We can use some of the more advanced features of TQMainWindow, which includes dockable toolbars. Adding these is simple with the TQt Designer. The final version of our project includes a toolbar, which provides quick access to the Open, Save, Print, New Page and Delete to Trash actions.

The possibilities are endless. An Edit menu, with the common Cut, Copy and Paste 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.

[ Previous: Replacing the Print Dialog ] [ Home ]


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8