1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:FDL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in a
|
---|
14 | ** written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Free Documentation License
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
---|
18 | ** Documentation License version 1.3 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file included in the packaging of this
|
---|
20 | ** file.
|
---|
21 | **
|
---|
22 | ** If you have questions regarding the use of this file, please contact
|
---|
23 | ** Nokia at [email protected].
|
---|
24 | ** $QT_END_LICENSE$
|
---|
25 | **
|
---|
26 | ****************************************************************************/
|
---|
27 |
|
---|
28 | /*!
|
---|
29 | \group helpsystem
|
---|
30 | \title Help System
|
---|
31 | \ingroup groups
|
---|
32 |
|
---|
33 | \brief Classes used to provide online-help for applications.
|
---|
34 |
|
---|
35 | \keyword help system
|
---|
36 |
|
---|
37 | These classes provide for all forms of online-help in your application,
|
---|
38 | with three levels of detail:
|
---|
39 |
|
---|
40 | \list 1
|
---|
41 | \o Tool Tips and Status Bar message - flyweight help, extremely brief,
|
---|
42 | entirely integrated in the user interface, requiring little
|
---|
43 | or no user interaction to invoke.
|
---|
44 | \o What's This? - lightweight, but can be
|
---|
45 | a three-paragraph explanation.
|
---|
46 | \o Online Help - can encompass any amount of information,
|
---|
47 | but is typically slower to call up, somewhat separated
|
---|
48 | from the user's work, and often users feel that using online
|
---|
49 | help is a digression from their real task.
|
---|
50 | \endlist
|
---|
51 |
|
---|
52 | */
|
---|
53 |
|
---|
54 | /*!
|
---|
55 | \page qthelp-framework.html
|
---|
56 | \title The Qt Help Framework
|
---|
57 | \brief Integrating Documentation in Applications
|
---|
58 | \ingroup frameworks-technologies
|
---|
59 |
|
---|
60 | \section1 Topics
|
---|
61 |
|
---|
62 | \tableofcontents
|
---|
63 |
|
---|
64 | \section1 Overview
|
---|
65 | The Qt help system includes tools for generating and viewing
|
---|
66 | Qt help files. In addition it provides classes for accessing
|
---|
67 | help contents programatically to be able to integrate online
|
---|
68 | help into Qt applications.
|
---|
69 |
|
---|
70 | The actual help data, meaning the table of contents, index
|
---|
71 | keywords or html documents, is contained in Qt compressed help
|
---|
72 | files. So, one such a help file represents usually one manual
|
---|
73 | or documentation set. Since most products are more comprehensive
|
---|
74 | and consist of a number of tools, one manual is rarely enough.
|
---|
75 | Instead, more manuals which should be accessible at the same
|
---|
76 | time, exist. Ideally, it should also be possible to reference
|
---|
77 | certain points of interest of one manual to another.
|
---|
78 | Therefore, the Qt help system operates on help collection files
|
---|
79 | which include any number of compressed help files.
|
---|
80 |
|
---|
81 | However, having collection files to merge many documentation
|
---|
82 | sets may lead to some problems. For example, one index keyword
|
---|
83 | may be defined in different documentations. So, when only seeing
|
---|
84 | it in the index and activating it, you cannot be sure that
|
---|
85 | the expected documentation will be shown. Therefore, the Qt
|
---|
86 | help system offers the possibiltiy to filter the help contents
|
---|
87 | after certain attributes. This requires however, that the
|
---|
88 | attributes have been assigned to the help contents before the
|
---|
89 | generation of the compressed help file.
|
---|
90 |
|
---|
91 | As already mentioned, the Qt compressed help file contains all
|
---|
92 | data, so there is no need any longer to ship all single html
|
---|
93 | files. Instead, only the compressed help file and optionally the
|
---|
94 | collection file has to be distributed. The collection file is
|
---|
95 | optional since any existing collection file, e.g. from an older
|
---|
96 | release could be used.
|
---|
97 |
|
---|
98 | So, in general, there are four files interacting with the help
|
---|
99 | system, two used for generating Qt help and two meant for
|
---|
100 | distribution:
|
---|
101 |
|
---|
102 | \table
|
---|
103 | \header
|
---|
104 | \o Name
|
---|
105 | \o Extension
|
---|
106 | \o Brief Description
|
---|
107 | \row
|
---|
108 | \o \l {Qt Help Project}
|
---|
109 | \o .qhp
|
---|
110 | \o The input file for the help generator consisting of the table
|
---|
111 | of contents, indices and references to the actual documentation
|
---|
112 | files (*.html); it also defines a unique namespace for the
|
---|
113 | documentation.
|
---|
114 |
|
---|
115 | \row
|
---|
116 | \o Qt Compressed Help
|
---|
117 | \o .qch
|
---|
118 | \o The output file of the help generator. This binary file contains
|
---|
119 | all information specified in the help project file along with all
|
---|
120 | compressed documentation files.
|
---|
121 |
|
---|
122 | \row
|
---|
123 | \o \l {Qt Help Collection Project}
|
---|
124 | \o .qhcp
|
---|
125 | \o The input file for the help collection generator. It contains
|
---|
126 | references to compressed help files which should be included in
|
---|
127 | the collection; it also may contain other information for
|
---|
128 | customizing Qt Assistant.
|
---|
129 |
|
---|
130 | \row
|
---|
131 | \o Qt Help Collection
|
---|
132 | \o .qhc
|
---|
133 | \o The output of the help collection generator. This is the file
|
---|
134 | QHelpEngine operates on. It contains references to any number of
|
---|
135 | compressed help files as well as additional information, such as
|
---|
136 | custom filters.
|
---|
137 | \endtable
|
---|
138 |
|
---|
139 | \section1 Generating Qt Help
|
---|
140 |
|
---|
141 | Building help files for the Qt help system assumes that the html
|
---|
142 | documentation files already exist, i.e. the Qt help system does
|
---|
143 | not offer the possibility to create html files like e.g. Doxygen.
|
---|
144 |
|
---|
145 | Once the html documentents are in place, a \l {Qt Help Project} file
|
---|
146 | has to be created. After specifying all relevant information in
|
---|
147 | this file, it needs to be compiled by calling:
|
---|
148 |
|
---|
149 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 2
|
---|
150 |
|
---|
151 | The file 'doc.qch' contains then all html files in compressed
|
---|
152 | form along with the table of contents and index keywords. To
|
---|
153 | test if the generated file is correct, open Qt Assistant and
|
---|
154 | install the file via the Settings|Documentation page.
|
---|
155 |
|
---|
156 | \target Qt Help Collection Project
|
---|
157 | \section2 Creating a Qt Help Collection
|
---|
158 |
|
---|
159 | The first step is to create a Qt Help Collection Project file.
|
---|
160 | Since a Qt help collection stores primarily references to
|
---|
161 | compressed help files, the project 'mycollection.qhcp' file
|
---|
162 | looks unsurprisingly simple:
|
---|
163 |
|
---|
164 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 3
|
---|
165 |
|
---|
166 | For actually creating the collection file call:
|
---|
167 |
|
---|
168 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 4
|
---|
169 |
|
---|
170 | Instead of running two tools, one for generating the compressed
|
---|
171 | help and one for generating the collection file, it is also
|
---|
172 | possible to just run the qcollectiongenerator tool with a
|
---|
173 | slightly modified project file instructing the generator to
|
---|
174 | create the compressed help first.
|
---|
175 |
|
---|
176 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 5
|
---|
177 |
|
---|
178 | Of course, it is possible to specify more than one file in the
|
---|
179 | 'generate' or 'register' section, so any number of compressed
|
---|
180 | help files can be generated and registered in one go.
|
---|
181 |
|
---|
182 | \section1 Using Qt Help
|
---|
183 |
|
---|
184 | Accessing the help contents can be done in two ways: Using Qt
|
---|
185 | Assistant as documentation browser or using the QHelpEngine
|
---|
186 | API for embedding the help contents directly in an application.
|
---|
187 |
|
---|
188 | \section2 Using Qt Assistant
|
---|
189 |
|
---|
190 | \QA operates on a collection file which can be specified
|
---|
191 | before start up. If no collection file is given, a default one
|
---|
192 | will be created and used. In either case, it is possible to
|
---|
193 | register any Qt compressed help file and access the help contents.
|
---|
194 |
|
---|
195 | When using Assistant as the help browser for an application, it
|
---|
196 | would be desirable that it can be customized to fit better to the
|
---|
197 | application and doesn't look like an independent, standalone
|
---|
198 | help browser. To achieve this, several additional properties can
|
---|
199 | be set in an Qt help collection file, to change e.g. the title
|
---|
200 | or application icon of Qt Assistant. For more information on
|
---|
201 | this topic have a look at the \l{assistant-manual.html}
|
---|
202 | {Qt Assistant manual}.
|
---|
203 |
|
---|
204 | \section2 Using QHelpEngine API
|
---|
205 |
|
---|
206 | Instead of showing the help in an external application like the
|
---|
207 | Qt Assistant, it is also possible to embed the online help in
|
---|
208 | the application. The contents can then be retrieved via the
|
---|
209 | QHelpEngine class and can be displayed in nearly any form.
|
---|
210 | Showing it in a QTextBrowser is probably the most common way, but
|
---|
211 | embedding it in What's This help is also perfectly possible.
|
---|
212 |
|
---|
213 | Retrieving help data from the file engine does not involve a
|
---|
214 | lot of code. The first step is to create an instance of the
|
---|
215 | help engine. Then we ask the engine for the links assigned to
|
---|
216 | the identifier, in this case "MyDialog::ChangeButton". If a link
|
---|
217 | was found, meaning at least one help document exists to this topic,
|
---|
218 | we get the actual help contents by calling fileData() and display
|
---|
219 | the document to the user.
|
---|
220 |
|
---|
221 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 6
|
---|
222 |
|
---|
223 | For further information on how to use the API, have a look at
|
---|
224 | the QHelpEngine class reference.
|
---|
225 | */
|
---|
226 |
|
---|
227 | /*!
|
---|
228 | \page qthelpproject.html
|
---|
229 | \title Qt Help Project
|
---|
230 |
|
---|
231 | A Qt help project collects all data necessary to generate a
|
---|
232 | compressed help file. Along with the actual help data, like
|
---|
233 | the table of contents, index keywords and help documents, it
|
---|
234 | contains some extra information like a namespace to identify
|
---|
235 | the help file. One help project stands for one documentation,
|
---|
236 | e.g. the Qt Assistant manual.
|
---|
237 |
|
---|
238 | \section1 Qt Help Project File Format
|
---|
239 |
|
---|
240 | The file format is XML-based. For a better understanding of
|
---|
241 | the format we'll discuss the following example:
|
---|
242 |
|
---|
243 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 7
|
---|
244 |
|
---|
245 | \section2 Namespace
|
---|
246 |
|
---|
247 | To enable the QHelpEngine to retrieve the proper documentation to
|
---|
248 | a given link, every documentation set has to have a unique
|
---|
249 | identifier. A unique identifier makes is also possible for the
|
---|
250 | help collection to keep track of a documentation set without relying
|
---|
251 | on its file name. The Qt help system uses a namespace as identifier
|
---|
252 | which is defined by the mandatory namespace tags. In the example
|
---|
253 | above, the namespace is "mycompany.com.myapplication.1.0".
|
---|
254 |
|
---|
255 | \target Virtual Folders
|
---|
256 | \section2 Virtual Folders
|
---|
257 |
|
---|
258 | Having a namespace for every documentation naturally means that
|
---|
259 | the documentation sets are quite separated. From the help engines
|
---|
260 | point of view this is beneficial, but from the documentors view
|
---|
261 | it is often desirable to cross reference certain topic from one
|
---|
262 | manual to another without having to specify absolute links. To
|
---|
263 | solve this problem, the help system introduced the concept of
|
---|
264 | virtual folders.
|
---|
265 |
|
---|
266 | A virtual folder will become the root directory of all files
|
---|
267 | referenced in a compressed help file. When two documentations
|
---|
268 | share the same virtual folder, they can use relative paths when
|
---|
269 | defining hyperlinks pointing to the other documentation. If a
|
---|
270 | file is contained in both documentations or manuals, the one
|
---|
271 | from the current manual has precedence over the other.
|
---|
272 |
|
---|
273 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 8
|
---|
274 |
|
---|
275 | The above example specifies 'doc' as virtual folder. If another
|
---|
276 | manual, e.g. for a small helper tool for 'My Application'
|
---|
277 | specifies the same folder, it is sufficient to write
|
---|
278 | 'doc.html#section1' to reference the first section in the
|
---|
279 | 'My Application' manual.
|
---|
280 |
|
---|
281 | The virtual folder tag is mandatory and the folder must not
|
---|
282 | contain any '/'.
|
---|
283 |
|
---|
284 | \target Custom Filters
|
---|
285 | \section2 Custom Filters
|
---|
286 |
|
---|
287 | Next in the Qt help project file are the optional definitions of
|
---|
288 | custom filters. A custom filter contains a list of filter
|
---|
289 | attributes which will be used later to display only the documentation
|
---|
290 | which has all those attributes assigned to. So, when setting the
|
---|
291 | current filter in the QHelpEngine to "My Application 1.0" only
|
---|
292 | the documentation which has "myapp" and "1.0" set as filter
|
---|
293 | attributes will be shown.
|
---|
294 |
|
---|
295 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 9
|
---|
296 |
|
---|
297 | It is possible to define any number of custom filters in a help
|
---|
298 | project file. Important to know is, that the filter attributes have
|
---|
299 | not to be specified in the same project file; they can be defined
|
---|
300 | in any other help file. The definition of a filter attributes
|
---|
301 | takes place by specifying them in a filter section.
|
---|
302 |
|
---|
303 | \target Filter Section
|
---|
304 | \section2 Filter Section
|
---|
305 |
|
---|
306 | A filter section contains the actual documentation. One Qt help project
|
---|
307 | file may contain more than one filter sections. Every filter section
|
---|
308 | consists of four parts, the filter attributes section, the table of
|
---|
309 | contents, the keywords and the files list. In theory all parts are
|
---|
310 | optional but not specifying anything there will result in an empty
|
---|
311 | documentation.
|
---|
312 |
|
---|
313 | \section3 Filter Attributes
|
---|
314 |
|
---|
315 | Every filter section should have filter attributes assigned to it, to
|
---|
316 | enable documentation filtering. If no filter attribute is defined, the
|
---|
317 | documentation will only be shown if no filtering occurs, meaning the
|
---|
318 | current custom filter in the QHelpEngine does not contain any filter
|
---|
319 | attributes.
|
---|
320 |
|
---|
321 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 10
|
---|
322 |
|
---|
323 | In this case, the filter attributes 'myapp' and '1.0' are assigned
|
---|
324 | to the filter section, i.e. all contents specified in this section
|
---|
325 | will only be shown if the current custom filter has 'myapp' or '1.0'
|
---|
326 | or both as filter attributes.
|
---|
327 |
|
---|
328 | \section3 Table of contents
|
---|
329 |
|
---|
330 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 11
|
---|
331 |
|
---|
332 | One section tag represents one item in the table of contents. The
|
---|
333 | sections can be nested to any degree, but from a users perspective
|
---|
334 | it should not be more than four or five levels. A section is defined
|
---|
335 | by its title and reference. The reference, like all file references in a Qt
|
---|
336 | help project, are relative to the help project file itself.
|
---|
337 | \note The referenced files must be inside the same directory (or within a
|
---|
338 | subdirectory) as the help project file. An absolute file path is not supported
|
---|
339 | either.
|
---|
340 |
|
---|
341 | \section3 Keywords
|
---|
342 |
|
---|
343 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 12
|
---|
344 |
|
---|
345 | The keyword section lists all keywords of this filter section. A
|
---|
346 | keyword consists basically of a name and a file reference. If the
|
---|
347 | attribute 'name' is used then the keyword specified there will appear in
|
---|
348 | the visible index, i.e. it will be accessible through the QHelpIndexModel.
|
---|
349 | If 'id' is used, the keyword does not appear in the index and is
|
---|
350 | only accessible via the linksForIdentifier() function of the
|
---|
351 | QHelpEngineCore. 'name' and 'id' can be specified at the same time.
|
---|
352 |
|
---|
353 | \section3 Files
|
---|
354 |
|
---|
355 | \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 13
|
---|
356 |
|
---|
357 | Finally, the actual documentation files have to be listed. Make sure
|
---|
358 | that all files neccessary to display the help are mentioned, i.e.
|
---|
359 | stylesheets or similar files need to be there as well. The files, like all
|
---|
360 | file references in a Qt help project, are relative to the help project file
|
---|
361 | itself. As the example shows, files (but not directories) can also be
|
---|
362 | specified as patterns using wildcards. All listed files will be compressed
|
---|
363 | and written to the Qt compressed help file. So, in the end, one single Qt
|
---|
364 | help file contains all documentation files along with the contents and
|
---|
365 | indices. \note The referenced files must be inside the same directory
|
---|
366 | (or within a subdirectory) as the help project file. An absolute file path
|
---|
367 | is not supported either.
|
---|
368 | */
|
---|