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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QtHelp Module

The QtHelp module provides classes for integrating online documentation in applications. More...

Classes

QHelpContentItemItem for use with QHelpContentModel
QHelpContentModelModel that supplies content to views
QHelpContentWidgetTree view for displaying help content model items
QHelpEngineAccess to contents and indices of the help engine
QHelpEngineCoreThe core functionality of the help system
QHelpIndexModelModel that supplies index keywords to views
QHelpIndexWidgetList view displaying the QHelpIndexModel
QHelpSearchEngineAccess to widgets reusable to integrate fulltext search as well as to index and search documentation
QHelpSearchQueryContains the field name and the associated search term
QHelpSearchQueryWidgetSimple line edit or an advanced widget to enable the user to input a search term in a standardized input mask
QHelpSearchResultWidgetEither a tree widget or a text browser depending on the used search engine to display the hits found by the search

Detailed Description

To include the definitions of the module's classes, use the following directive:

 #include <QtHelp>

To link against the module, add this line to your qmake .pro file:

 CONFIG += help

Note: These classes are part of the Open Source Versions of Qt and Qt Full Framework Edition for commercial users.

Topics

Overview

The Qt help system includes tools for generating and viewing Qt help files. In addition it provides classes for accessing help contents programatically to be able to integrate online help into Qt applications.

The actual help data, meaning the table of contents, index keywords or html documents, is contained in Qt compressed help files. So, one such a help file represents usually one manual or documentation set. Since most products are more comprehensive and consist of a number of tools, one manual is rarely enough. Instead, more manuals which should be accessible at the same time, exist. Ideally, it should also be possible to reference certain points of interest of one manual to another. Therefore, the Qt help system operates on help collection files which include any number of compressed help files.

However, having collection files to merge many documentation sets may lead to some problems. For example, one index keyword may be defined in different documentations. So, when only seeing it in the index and activating it, you cannot be sure that the expected documentation will be shown. Therefore, the Qt help system offers the possibiltiy to filter the help contents after certain attributes. This requires however, that the attributes have been assigned to the help contents before the generation of the compressed help file.

As already mentioned, the Qt compressed help file contains all data, so there is no need any longer to ship all single html files. Instead, only the compressed help file and optionally the collection file has to be distributed. The collection file is optional since any existing collection file, e.g. from an older release could be used.

So, in general, there are four files interacting with the help system, two used for generating Qt help and two meant for distribution:

NameExtensionBrief Description
Qt Help Project.qhpThe input file for the help generator consisting of the table of contents, indices and references to the actual documentation files (*.html); it also defines a unique namespace for the documentation.
Qt Compressed Help.qchThe output file of the help generator. This binary file contains all information specified in the help project file along with all compressed documentation files.
Qt Help Collection Project.qhcpThe input file for the help collection generator. It contains references to compressed help files which should be included in the collection; it also may contain other information for customizing Qt Assistant.
Qt Help Collection.qhcThe output of the help collection generator. This is the file QHelpEngine operates on. It contains references to any number of compressed help files as well as additional information, such as custom filters.

Generating Qt Help

Building help files for the Qt help system assumes that the html documentation files already exist, i.e. the Qt help system does not offer the possibility to create html files like e.g. Doxygen.

Once the html documentents are in place, a Qt Help Project file has to be created. After specifying all relevant information in this file, it needs to be compiled by calling:

 qhelpgenerator doc.qhp -o doc.qch

The file 'doc.qch' contains then all html files in compressed form along with the table of contents and index keywords. To test if the generated file is correct, open Qt Assistant and install the file via the Settings|Documentation page.

Creating a Qt Help Collection

The first step is to create a Qt Help Collection Project file. Since a Qt help collection stores primarily references to compressed help files, the project 'mycollection.qhcp' file looks unsurprisingly simple:

 <?xml version="1.0" encoding="utf-8" ?>
 <QHelpCollectionProject version="1.0">
     <docFiles>
         <register>
             <file>doc.qch</file>
         </register>
     </docFiles>
 </QHelpCollectionProject>

For actually creating the collection file call:

 qcollectiongenerator mycollection.qhcp -o mycollection.qhc

Instead of running two tools, one for generating the compressed help and one for generating the collection file, it is also possible to just run the qcollectiongenerator tool with a slightly modified project file instructing the generator to create the compressed help first.

 ...
 <docFiles>
     <generate>
         <file>
             <input>doc.qhp</input>
             <output>doc.qch</output>
         </file>
     </generate>
     <register>
         <file>doc.qch</file>
     </register>
 </docFiles>
 ...

Of course, it is possible to specify more than one file in the 'generate' or 'register' section, so any number of compressed help files can be generated and registered in one go.

Using Qt Help

Accessing the help contents can be done in two ways: Using Qt Assistant as documentation browser or using the QHelpEngine API for embedding the help contents directly in an application.

Using Qt Assistant

Qt Assistant operates on a collection file which can be specified before start up. If no collection file is given, a default one will be created and used. In either case, it is possible to register any Qt compressed help file and access the help contents.

When using Assistant as the help browser for an application, it would be desirable that it can be customized to fit better to the application and doesn't look like an independent, standalone help browser. To achieve this, several additional properties can be set in an Qt help collection file, to change e.g. the title or application icon of Qt Assistant. For more information on this topic have a look at the Qt Assistant manual.

Using QHelpEngine API

Instead of showing the help in an external application like the Qt Assistant, it is also possible to embed the online help in the application. The contents can then be retrieved via the QHelpEngine class and can be displayed in nearly any form. Showing it in a QTextBrowser is probably the most common way, but embedding it in What's This help is also perfectly possible.

Retrieving help data from the file engine does not involve a lot of code. The first step is to create an instance of the help engine. Then we ask the engine for the links assigned to the identifier, in this case "MyDialog::ChangeButton". If a link was found, meaning at least one help document exists to this topic, we get the actual help contents by calling fileData() and display the document to the user.

 QHelpEngineCore helpEngine("mycollection.qhc");
 ...

 // get all file references for the identifier
 QMap<QString, QUrl> links =
     helpEngine.linksForIdentifier(QLatin1String("MyDialog::ChangeButton"));

 // If help is available for this keyword, get the help data
 // of the first file reference.
 if (links.count()) {
     QByteArray helpData = helpEngine->fileData(links.constBegin().value());
     // show the documentation to the user
     if (!helpData.isEmpty())
         displayHelp(helpData);
 }

For further information on how to use the API, have a look at the QHelpEngine class reference.

License Information

The QtHelp module uses the CLucene indexing library to provide full-text searching capabilities for Qt Assistant and applications that use the features of QtHelp.

Qt Commercial Edition licensees that wish to distribute applications that use these features of the QtHelp module need to be aware of their obligations under the GNU Lesser General Public License (LGPL).

Developers using the Open Source Edition can choose to redistribute the module under the appropriate version of the GNU LGPL; version 2.1 for applications and libraries licensed under the GNU GPL version 2, or version 3 for applications and libraries licensed under the GNU GPL version 3.

Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
Changes are Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

[Previous: QtUiTools Module] [Qt's Modules] [Next: QtAssistant Module]

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 64
  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. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  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. La rubrique Qt a besoin de vous ! 1
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le 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 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 4.5
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