Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qthelp.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\group helpsystem
6
\title Help System
7
\ingroup groups
8
9
\brief Classes used to provide online-help for applications.
10
11
\keyword help system
12
13
These classes provide online-help for your application,
14
with three levels of detail:
15
16
\list 1
17
\li Tool Tips and Status Bar message - flyweight help, extremely brief,
18
entirely integrated in the user interface, requiring little
19
or no user interaction to invoke.
20
\li What's This? - lightweight, but can be
21
a three-paragraph explanation.
22
\li Online Help - can encompass any amount of information,
23
but is typically slower to call up, somewhat separated
24
from the user's work, and often users feel that using online
25
help is a digression from their real task.
26
\endlist
27
28
*/
29
30
/*!
31
\page qthelp-framework.html
32
\title The Qt Help Framework
33
\brief Integrating Documentation in Applications
34
\ingroup frameworks-technologies
35
36
\section1 Overview
37
The Qt help system includes tools for generating and viewing
38
Qt help files. In addition, it provides classes for accessing
39
help contents programmatically to be able to integrate online
40
help into Qt applications.
41
42
The actual help data, meaning the table of contents, index
43
keywords, or HTML documents, is contained in Qt compressed help
44
files. So, one such a help file represents usually one manual
45
or documentation set. Since most products are more comprehensive
46
and consist of a number of tools, one manual is rarely enough.
47
Instead, more manuals, which should be accessible at the same
48
time, exist. Ideally, it should also be possible to reference
49
certain points of interest of one manual to another.
50
Therefore, the Qt help system operates on help collection files,
51
which include any number of compressed help files.
52
53
However, having collection files to merge many documentation
54
sets may lead to some problems. For example, one index keyword
55
may be defined in different documentation sets. So, when only seeing
56
a keyword in the index and activating it, you cannot be sure that
57
the expected documentation will be shown. Therefore, the Qt
58
help system offers the possibility to filter the help contents
59
after certain attributes. This requires, however, that the
60
attributes have been assigned to the help contents before the
61
generation of the compressed help file.
62
63
As already mentioned, the Qt compressed help file contains all
64
data, so there is no need any longer to ship all the single HTML
65
files. Instead, only the compressed help file and, optionally, the
66
collection file have to be distributed. The collection file is
67
optional since any existing collection file, for example from an older
68
release, could be used.
69
70
\note The Qt compressed help files (.qch) should only be loaded
71
from trusted sources.
72
73
So, in general, there are four files interacting with the help
74
system, two used for generating Qt help and two meant for
75
distribution:
76
77
\table
78
\header
79
\li Name
80
\li Extension
81
\li Brief Description
82
\row
83
\li \l {Qt Help Project}
84
\li .qhp
85
\li Contains the table of contents, indices, and references to the
86
actual documentation files (*.html). It also defines a unique
87
namespace for the documentation. This file is passed to the help
88
generator for creating a compressed help file.
89
90
\row
91
\li Qt Compressed Help
92
\li .qch
93
\li Contains all the information specified in the help project file
94
along with all the compressed documentation files.
95
96
\row
97
\li \l {Qt Help Collection Project}
98
\li .qhcp
99
\li An XML file that contains references to the compressed help
100
files that should be included in the help collection. This file
101
can be passed to the help generator for creating a help collection
102
file.
103
104
\row
105
\li Qt Help Collection
106
\li .qhc
107
\li The help collection file that QHelpEngine operates on. It can
108
contain references to any number of compressed help files as
109
well as additional information.
110
\endtable
111
112
\section1 Generating Qt Help
113
114
Building help files for the Qt help system assumes that the HTML
115
documentation files already exist.
116
117
Once the HTML documents are in place, a \l {Qt Help Project} file, with
118
an extension of \c .qhp, has to be created. After specifying all the relevant
119
information in this file, it needs to be compiled by calling:
120
121
\snippet doc_src_qthelp.qdoc 2
122
123
The file \e doc.qch contains all the HTML files in compressed
124
form along with the table of contents and index keywords. To
125
test if the generated file is correct, open Qt Assistant and
126
install the file in \uicontrol Settings > \uicontrol Documentation.
127
128
For the standard Qt source build, the .qhp file is generated and placed
129
in the same directory as the HTML pages.
130
131
\target Qt Help Collection Project
132
\section2 Creating a Qt Help Collection
133
134
The first step is to create a Qt Help Collection Project file.
135
Since a Qt help collection stores primarily references to
136
compressed help files, the project \e mycollection.qhcp file
137
looks unsurprisingly simple:
138
139
\snippet doc_src_qthelp.qdoc 3
140
141
For actually creating the collection file call:
142
143
\snippet doc_src_qthelp.qdoc 4
144
145
To generate both the compressed help and the collection file in one go,
146
modify the help collection project file so that it instructs the help
147
generator to create the compressed help first:
148
149
\snippet doc_src_qthelp.qdoc 5
150
151
Of course, it is possible to specify more than one file in the
152
\c generate or \c register section, so any number of compressed
153
help files can be generated and registered in one go.
154
155
\section1 Using QHelpEngine API
156
157
QHelpEngine allows embedding the help contents directly in an
158
application.
159
160
Instead of showing the help in an external application such as a
161
web browser, it is also possible to embed the online help in
162
the application. The contents can then be retrieved via the
163
QHelpEngine class and can be displayed in nearly any form.
164
Showing the help in a QTextBrowser is probably the most common way, but
165
embedding it in What's This help is also perfectly possible.
166
167
Retrieving help data from the file engine does not involve a
168
lot of code. The first step is to create an instance of the
169
help engine. Then we ask the engine for the links assigned to
170
the identifier, in this case \c MyDialog::ChangeButton. If a link
171
was found, meaning at least one help document exists on this topic,
172
we get the actual help contents by calling QHelpEngineCore::fileData() and
173
display the document to the user.
174
175
\snippet doc_src_qthelp.cpp 6
176
177
For further information on how to use the API, have a look at
178
the QHelpEngine class reference.
179
*/
180
181
/*!
182
\page qthelpproject.html
183
\title Qt Help Project
184
185
A Qt help project collects all data necessary to generate a
186
compressed help file. Along with the actual help data, like
187
the table of contents, index keywords and help documents, it
188
contains some extra information like a namespace to identify
189
the help file. One help project stands for one documentation set,
190
for example the \l{qmake Manual}.
191
192
\section1 Qt Help Project File Format
193
194
The file format is XML-based. For a better understanding of
195
the format we will discuss the following example:
196
197
\snippet doc_src_qthelp.qdoc 7
198
199
\section2 Namespace
200
201
To enable the QHelpEngine to retrieve the proper documentation to
202
a given link, every documentation set has to have a unique
203
identifier. A unique identifier also makes it possible for the
204
help collection to keep track of a documentation set without relying
205
on its file name. The Qt help system uses a namespace as identifier
206
which is defined by the mandatory namespace tags. In the example
207
above, the namespace is "mycompany.com.myapplication.1.0".
208
209
\target Virtual Folders
210
\section2 Virtual Folders
211
212
Having a namespace for every documentation set naturally means that
213
the documentation sets are quite separated. From the help engine's
214
point of view, this is beneficial. However, from the writer's view
215
it is often desirable to cross reference certain topics from one
216
manual to another without having to specify absolute links. To
217
solve this problem, the help system introduced the concept of
218
virtual folders.
219
220
A virtual folder will become the root directory of all files
221
referenced in a compressed help file. When two documentation sets
222
share the same virtual folder, they can use relative paths when
223
defining hyperlinks pointing to each other. If a file is contained
224
in both documentation sets, the one from the current set has
225
precedence over the other.
226
227
\snippet doc_src_qthelp.qdoc 8
228
229
The above example specifies \e doc as virtual folder. If another
230
manual specifies the same folder, for example for a small helper
231
tool \e {My Application}, it is sufficient to write
232
\e {doc.html#section1} to reference the first section in the
233
\e {My Application} manual.
234
235
The virtual folder tag is mandatory and the folder name must not
236
contain any slashes (/).
237
238
\target Filter Section
239
\section2 Filter Section
240
241
A filter section contains the actual documentation. A Qt help project
242
file may contain more than one filter section. Every filter section
243
consists of the table of contents, the keywords, and the files list.
244
In theory all parts are optional but not specifying anything there will
245
result in an empty documentation set.
246
247
\section3 Table of Contents
248
249
\snippet doc_src_qthelp.qdoc 11
250
251
One section tag represents one item in the table of contents. The
252
sections can be nested to any degree, but from a user's perspective
253
it should not be more than four or five levels. A section is defined
254
by its title and reference. The reference, like all file references in a Qt
255
help project, are relative to the help project file itself.
256
\note The referenced files must be in the same directory as the help
257
project file (or in a subdirectory). An absolute file path is not supported
258
either.
259
260
\section3 Keywords
261
262
\snippet doc_src_qthelp.qdoc 12
263
264
The keyword section lists all keywords of this filter section. A
265
keyword consists basically of a name and a file reference. If the
266
attribute \e name is used, the keyword specified there will appear in the
267
visible index. That is, it will be accessible through the QHelpIndexModel
268
class. If \e id is used, the keyword does not appear in the index and is
269
only accessible via \l QHelpEngineCore::documentsForIdentifier(). \e name
270
and \e id can be specified at the same time.
271
272
\section3 Files
273
274
\snippet doc_src_qthelp.qdoc 13
275
276
Finally, the actual documentation files have to be listed. Make sure
277
that all files necessary to display the help are mentioned. That is,
278
stylesheets or similar files need to be listed as well. The files, like all
279
file references in a Qt help project, are relative to the help project file
280
itself. As the example shows, files (but not directories) can also be
281
specified as patterns using wildcards. All listed files will be compressed
282
and written to the Qt compressed help file. So, in the end, one single Qt
283
help file contains all documentation files along with the contents and
284
indices. \note The referenced files must be inside the same directory
285
as the help project file (or in a subdirectory). An absolute file path
286
is not supported either.
287
*/
qttools
src
assistant
help
doc
src
qthelp.qdoc
Generated on
for Qt by
1.16.1