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  · 

Using Custom QDialogs

[ Previous: Using Qt Standard Dialogs ] [ Home ] [ Next: Using Existing Dialogs with QMotifDialog ]

After we have replaced the standard dialogs, we move onto the custom dialogs. This project has a single custom dialog: the Page Edit dialog.

Instead of writing the code ourselves, we use Qt Designer to design our dialog. Designing a custom dialog is beyond the scope of this document: see the Qt Designer Manual if you're unfamiliar with Qt's visual design tool.

Replacing the Page Edit Dialog

The custom QDialog description for the Page Edit dialog is saved as pageeditdialog.ui. We add this file to the project file by adding the line

FORMS = pageeditdialog.ui
to the .pro file, and regenerate the Makefile. The uic utility generates the code for our custom QDialog, which is then compiled and linked into our application. (uic is invoked automatically from makefiles generated from .pro files.)

We need to pass the top-level QMotifWidget as the client_data argument to the EditPage function, which we will use as the parent for our new PageEditDialog. We do this the same way as we have done for the Open and Save As dialogs in todo.cpp.


The EditPage() function is implemented in actions.cpp. We start by adding the includes needed for the PageEditDialog and QLineEdit.


In the EditPage() function, We create the PageEditDialog, set the initial values of the three QLineEdit widgets with values from the current page and execute the dialog.

    ...

At this point in the code, the page properties should be modified. The code to do this is in the DoEditPage() function. We move the contents of DoEditPage() to this point and remove the DoEditPage() function completely.

The Page struct defined in page.h stores strings in char* arrays. Since the PageEditDialog and the data it contains will be destroyed when we return from this function, we need to convert the unicode QString data into a QCString in the local encoding and duplicate it with qstrdup().


The same process must be done for the minorTab text:


... and for the majorTab text:


[ Previous: Using Qt Standard Dialogs ] [ Home ] [ Next: Using Existing Dialogs with QMotifDialog ]

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 42
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 9
Page suivante

Le Qt Labs au hasard

Logo

Velours et QML Scene Graph

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