Continuing Development[ Previous: Replacing the Print Dialog ] [ Home ]We have not quite finished with the migration to Qt, even though our project does not use Motif any more. Qt 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 UnicodeSupport for internationalization is very easy with Qt. Using QString 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 QString properly. Since QString 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 qstrdup() function, and we never need to use new or delete when done with a string. QString 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 qstrdup() 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 CodeQt 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 QFile and QTextStream 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 InterfaceSince we used the Qt Designer to design the Main Window widget, we can extend the interface easily. We can use some of the more advanced features of QMainWindow, which includes dockable toolbars. Adding these is simple with the Qt 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 Qt/Embedded. [ Previous: Replacing the Print Dialog ] [ Home ]
|
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le blog Digia au hasardDéploiement d'applications Qt Commercial sur les tablettes Windows 8Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.
CommunautéRessources
Liens utilesContact
Qt dans le magazine |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 3.3 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com