Qt Motif Extension - A Migration Walkthrough[ Next: Getting Started ]This walkthrough covers a complete migration of a Motif based program to the Qt toolkit using the Qt Motif Extension. It is rarely practical for a large project with hundreds of thousands or even millions of lines of code to be migrated all at once; such an endeavor would require too many development resources and would incur significant risks. Every line of code would have to be rewritten, every user interface redesigned, and quality assurance tests and procedures all rewritten. The Qt Motif Extension provides a complete and working solution for incremental migration that can be paced to suit each individual project and the available resources. The user interface and related code can be migrated in steps while the rest of the project need not be changed at all. This walkthrough is intended for programmers who will be migrating an existing Motif based project to the Qt toolkit. We assume that they have experience with C/C++ and Xt/Motif. Some experience with the Qt toolkit is also necessary. For developers completely new to Qt we recommend following the learning plan outlined in How to Learn Qt; or to go on a Qt training course. (See http://www.trolltech.com for details of training courses.)
Goals for the WalkthroughThe goal of this walkthrough is to provide the reader with enough knowledge to migrate Motif applications to the Qt toolkit. We will do this by example: We will convert a real-world Motif based program step-by-step. This walkthrough will discuss both techniques and their rationales throughout the process. This walkthrough is broken down into individual chapters which cover a specific topic:
We will use the todo demo program included with the Motif 2.x distribution as our migration project. This walkthrough contains references to the source code, which is included in the extensions/motif/examples/walkthrough subdirectory.
PrerequisitesBefore we can start using the Qt Motif Extension, we must satisfy these requirements:
X11R6.x and Motif 2.x LibrariesThe mechanisms used by the Qt Motif Extension require development headers and libraries from the X11R6 release and the Motif 2.0 release. Newer versions of these can also be used.
C++ CompilerSince Qt is a C++ toolkit, all new code will be written in C++. In order for existing code to coexist with new code, a C++ compiler must be able to compile the existing code. It is possible to keep existing code and new code separate, and only convert or rewrite existing code as needed. This is a normal part of the migration process, and does not need to be done before the migration process begins. This is the most common scenario, and we will demonstrate it by migrating existing C code to C++ as needed in this walkthrough.
Build and Install the Qt Motif ExtensionThe Qt Motif Extension is not built and installed along with the Qt toolkit. The extension resides in the extensions/motif subdirectory. Run make in this directory to build the extension and the examples. Once the extension has been built, run make install.
$ cd extensions/motif $ make $ make install The Qt Motif Extension is now installed and ready to use.
Build and Link the Project with the Qt Toolkit and the Qt Motif ExtensionFor simplicity, we use qmake to create the Makefile. The -project option causes qmake to automatically generate a project file. After qmake -project has generated our project file, we run qmake again to generate a Makefile. Now, we can just run make to build our project.
$ qmake -project $ qmake $ make Everything builds correctly, but fails to link because we don't link with the Motif library. We tell qmake to do this by adding the -lXm to the LIBS variable in our project file. Since we are planning to use the Qt Motif Extension in this project as well, we should also add -lqmotif to the list of libraries.
LIBS += -lXm -lqmotif Now we regenerate our Makefile by running qmake again, and rebuild using make. This time, our project successfully links, and the application runs as expected. We are now ready to start using the Qt Motif Extension.
|
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le Qt Developer Network au hasardGénération de bindings PySide avec ShibokenLe Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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.2 | |
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