~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qthelp-framework.html

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- qthelp.qdoc -->
 
6
<head>
 
7
  <title>Qt 4.6: The Qt Help Framework</title>
 
8
  <link href="classic.css" rel="stylesheet" type="text/css" />
 
9
</head>
 
10
<body>
 
11
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
12
<tr>
 
13
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
 
14
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td><td class="searchBar" align="right" valign="center"><form action="http://www.google.com/cse" id="cse-search-box"><div><input type="hidden" name="cx" value="000136343326384750312:dhbxnqlakyu" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="31" /><input type="submit" name="sa" value="Search" /></div></form></td>
 
15
</tr></table><h1 class="title">The Qt Help Framework<br /><span class="subtitle"></span>
 
16
</h1>
 
17
<a name="topics"></a>
 
18
<h3>Topics</h3>
 
19
<ul><li><a href="#topics">Topics</a></li>
 
20
<li><a href="#overview">Overview</a></li>
 
21
<li><a href="#generating-qt-help">Generating Qt Help</a></li>
 
22
<ul><li><a href="#creating-a-qt-help-collection">Creating a Qt Help Collection</a></li>
 
23
</ul>
 
24
<li><a href="#using-qt-help">Using Qt Help</a></li>
 
25
<ul><li><a href="#using-qt-assistant">Using Qt Assistant</a></li>
 
26
<li><a href="#using-qhelpengine-api">Using QHelpEngine API</a></li>
 
27
</ul>
 
28
</ul>
 
29
<a name="overview"></a>
 
30
<h3>Overview</h3>
 
31
<p>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.</p>
 
32
<p>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.</p>
 
33
<p>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.</p>
 
34
<p>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&#x2e; from an older release could be used.</p>
 
35
<p>So, in general, there are four files interacting with the help system, two used for generating Qt help and two meant for distribution:</p>
 
36
<p><table class="generic" align="center" cellpadding="2" cellspacing="1" border="0">
 
37
<thead><tr valign="top" class="qt-style"><th>Name</th><th>Extension</th><th>Brief Description</th></tr></thead>
 
38
<tr valign="top" class="odd"><td><a href="qthelpproject.html">Qt Help Project</a></td><td>.qhp</td><td>The 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.</td></tr>
 
39
<tr valign="top" class="even"><td>Qt Compressed Help</td><td>.qch</td><td>The output file of the help generator. This binary file contains all information specified in the help project file along with all compressed documentation files.</td></tr>
 
40
<tr valign="top" class="odd"><td><a href="#qt-help-collection-project">Qt Help Collection Project</a></td><td>.qhcp</td><td>The 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.</td></tr>
 
41
<tr valign="top" class="even"><td>Qt Help Collection</td><td>.qhc</td><td>The output of the help collection generator. This is the file <a href="qhelpengine.html">QHelpEngine</a> operates on. It contains references to any number of compressed help files as well as additional information, such as custom filters.</td></tr>
 
42
</table></p>
 
43
<a name="generating-qt-help"></a>
 
44
<h3>Generating Qt Help</h3>
 
45
<p>Building help files for the Qt help system assumes that the html documentation files already exist, i.e&#x2e; the Qt help system does not offer the possibility to create html files like e.g&#x2e; Doxygen.</p>
 
46
<p>Once the html documentents are in place, a <a href="qthelpproject.html">Qt Help Project</a> file has to be created. After specifying all relevant information in this file, it needs to be compiled by calling:</p>
 
47
<pre> qhelpgenerator doc.qhp -o doc.qch</pre>
 
48
<p>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.</p>
 
49
<a name="qt-help-collection-project"></a><a name="creating-a-qt-help-collection"></a>
 
50
<h4>Creating a Qt Help Collection</h4>
 
51
<p>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:</p>
 
52
<pre> &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
 
53
 &lt;QHelpCollectionProject version=&quot;1.0&quot;&gt;
 
54
     &lt;docFiles&gt;
 
55
         &lt;register&gt;
 
56
             &lt;file&gt;doc.qch&lt;/file&gt;
 
57
         &lt;/register&gt;
 
58
     &lt;/docFiles&gt;
 
59
 &lt;/QHelpCollectionProject&gt;</pre>
 
60
<p>For actually creating the collection file call:</p>
 
61
<pre> qcollectiongenerator mycollection.qhcp -o mycollection.qhc</pre>
 
62
<p>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.</p>
 
63
<pre> ...
 
64
 &lt;docFiles&gt;
 
65
     &lt;generate&gt;
 
66
         &lt;file&gt;
 
67
             &lt;input&gt;doc.qhp&lt;/input&gt;
 
68
             &lt;output&gt;doc.qch&lt;/output&gt;
 
69
         &lt;/file&gt;
 
70
     &lt;/generate&gt;
 
71
     &lt;register&gt;
 
72
         &lt;file&gt;doc.qch&lt;/file&gt;
 
73
     &lt;/register&gt;
 
74
 &lt;/docFiles&gt;
 
75
 ...</pre>
 
76
<p>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.</p>
 
77
<a name="using-qt-help"></a>
 
78
<h3>Using Qt Help</h3>
 
79
<p>Accessing the help contents can be done in two ways: Using Qt Assistant as documentation browser or using the <a href="qhelpengine.html">QHelpEngine</a> API for embedding the help contents directly in an application.</p>
 
80
<a name="using-qt-assistant"></a>
 
81
<h4>Using Qt Assistant</h4>
 
82
<p><i>Qt Assistant</i> 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.</p>
 
83
<p>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&#x2e; the title or application icon of Qt Assistant. For more information on this topic have a look at the <a href="assistant-manual.html">Qt Assistant manual</a>.</p>
 
84
<a name="using-qhelpengine-api"></a>
 
85
<h4>Using QHelpEngine API</h4>
 
86
<p>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 <a href="qhelpengine.html">QHelpEngine</a> class and can be displayed in nearly any form. Showing it in a <a href="qtextbrowser.html">QTextBrowser</a> is probably the most common way, but embedding it in What's This help is also perfectly possible.</p>
 
87
<p>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 &quot;MyDialog::ChangeButton&quot;. 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.</p>
 
88
<pre> QHelpEngineCore helpEngine(&quot;mycollection.qhc&quot;);
 
89
 ...
 
90
 
 
91
 // get all file references for the identifier
 
92
 QMap&lt;QString, QUrl&gt; links =
 
93
     helpEngine.linksForIdentifier(QLatin1String(&quot;MyDialog::ChangeButton&quot;));
 
94
 
 
95
 // If help is available for this keyword, get the help data
 
96
 // of the first file reference.
 
97
 if (links.count()) {
 
98
     QByteArray helpData = helpEngine-&gt;fileData(links.constBegin().value());
 
99
     // show the documentation to the user
 
100
     if (!helpData.isEmpty())
 
101
         displayHelp(helpData);
 
102
 }</pre>
 
103
<p>For further information on how to use the API, have a look at the <a href="qhelpengine.html">QHelpEngine</a> class reference.</p>
 
104
<p /><address><hr /><div align="center">
 
105
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
106
<td width="40%" align="left">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
 
107
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
108
<td width="40%" align="right"><div align="right">Qt 4.6.0</div></td>
 
109
<script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script><script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse-search-box&t13n_langs=en"></script><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script></tr></table></div></address></body>
 
110
</html>