Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Fonctions  · 

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 Walkthrough

The 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.

Prerequisites

Before we can start using the Qt Motif Extension, we must satisfy these requirements:

  1. We are using the X11R6.x and Motif 2.x libraries.
  2. The project is compilable by a C++ compiler.
  3. We have built and installed the Qt Motif Extension.
  4. We have built and linked the project with the Qt toolkit and the Qt Motif Extension

X11R6.x and Motif 2.x Libraries

The 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++ Compiler

Since 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 Extension

The 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 Extension

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 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.

[ Next: Getting Started ]

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 71
  2. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  3. Une nouvelle ère d'IHM 3D pour les automobiles, un concept proposé par Digia et implémenté avec Qt 3
  4. Qt Creator 2.5 est sorti en beta, l'EDI supporte maintenant plus de fonctionnalités de C++11 2
  5. Vingt sociétés montrent leurs décodeurs basés sur Qt au IPTV World Forum, en en exploitant diverses facettes (déclaratif, Web, widgets) 0
  6. PySide devient un add-on Qt et rejoint le Qt Project et le modèle d'open gouvernance 1
  7. Thread travailleur avec Qt en utilisant les signaux et les slots, un article de Christophe Dumez traduit par Thibaut Cuvelier 1
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 101
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 51
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 69
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 229
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
  7. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 101
Page suivante

Le Qt Labs au hasard

Logo

Le moteur de rendu OpenGL

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

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 !
 
 
 
 
Partenaires

Hébergement Web