Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
This walkthrough covers a complete migration of a Motif based program to the TQt toolkit using the TQt 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 retquire 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 TQt 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 TQt toolkit. We assume that they have experience with C/C++ and Xt/Motif. Some experience with the TQt toolkit is also necessary. For developers completely new to TQt we recommend following the learning plan outlined in How to Learn TQt; or to go on a TQt training course. (See http://www.trolltech.com for details of training courses.)
The goal of this walkthrough is to provide the reader with enough knowledge to migrate Motif applications to the TQt 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.
Before we can start using the TQt Motif Extension, we must satisfy these retquirements:
The mechanisms used by the TQt Motif Extension retquire development headers and libraries from the X11R6 release and the Motif 2.0 release. Newer versions of these can also be used.
Since TQt 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.
The TQt Motif Extension is not built and installed along with the TQt 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 TQt Motif Extension is now installed and ready to use.
For 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 TQt 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 TQt Motif Extension.
Copyright © 2007 Trolltech | Trademarks | TQt 3.3.8
|