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
\warning Only register compressed help files (.qch) that come from a
71
source that you trust. Registering and viewing a help file from an
72
untrusted source is a security risk. For more information, see
73
\l{qthelp-security-considerations}{Security Considerations}.
74
75
So, in general, there are four files interacting with the help
76
system, two used for generating Qt help and two meant for
77
distribution:
78
79
\table
80
\header
81
\li Name
82
\li Extension
83
\li Brief Description
84
\row
85
\li \l {Qt Help Project}
86
\li .qhp
87
\li Contains the table of contents, indices, and references to the
88
actual documentation files (*.html). It also defines a unique
89
namespace for the documentation. This file is passed to the help
90
generator for creating a compressed help file.
91
92
\row
93
\li Qt Compressed Help
94
\li .qch
95
\li Contains all the information specified in the help project file
96
along with all the compressed documentation files.
97
98
\row
99
\li \l {Qt Help Collection Project}
100
\li .qhcp
101
\li An XML file that contains references to the compressed help
102
files that should be included in the help collection. This file
103
can be passed to the help generator for creating a help collection
104
file.
105
106
\row
107
\li Qt Help Collection
108
\li .qhc
109
\li The help collection file that QHelpEngine operates on. It can
110
contain references to any number of compressed help files as
111
well as additional information.
112
\endtable
113
114
\section1 Generating Qt Help
115
116
Building help files for the Qt help system assumes that the HTML
117
documentation files already exist.
118
119
Once the HTML documents are in place, a \l {Qt Help Project} file, with
120
an extension of \c .qhp, has to be created. After specifying all the relevant
121
information in this file, it needs to be compiled by calling:
122
123
\snippet doc_src_qthelp.qdoc 2
124
125
The file \e doc.qch contains all the HTML files in compressed
126
form along with the table of contents and index keywords. To
127
test if the generated file is correct, open Qt Assistant and
128
install the file in \uicontrol Settings > \uicontrol Documentation.
129
130
For the standard Qt source build, the .qhp file is generated and placed
131
in the same directory as the HTML pages.
132
133
\target Qt Help Collection Project
134
\section2 Creating a Qt Help Collection
135
136
The first step is to create a Qt Help Collection Project file.
137
Since a Qt help collection stores primarily references to
138
compressed help files, the project \e mycollection.qhcp file
139
looks unsurprisingly simple:
140
141
\snippet doc_src_qthelp.qdoc 3
142
143
For actually creating the collection file call:
144
145
\snippet doc_src_qthelp.qdoc 4
146
147
To generate both the compressed help and the collection file in one go,
148
modify the help collection project file so that it instructs the help
149
generator to create the compressed help first:
150
151
\snippet doc_src_qthelp.qdoc 5
152
153
Of course, it is possible to specify more than one file in the
154
\c generate or \c register section, so any number of compressed
155
help files can be generated and registered in one go.
156
157
\section1 Using QHelpEngine API
158
159
QHelpEngine allows embedding the help contents directly in an
160
application.
161
162
Instead of showing the help in an external application such as a
163
web browser, it is also possible to embed the online help in
164
the application. The contents can then be retrieved via the
165
QHelpEngine class and can be displayed in nearly any form.
166
Showing the help in a QTextBrowser is probably the most common way, but
167
embedding it in What's This help is also perfectly possible.
168
169
Retrieving help data from the file engine does not involve a
170
lot of code. The first step is to create an instance of the
171
help engine. Then we ask the engine for the links assigned to
172
the identifier, in this case \c MyDialog::ChangeButton. If a link
173
was found, meaning at least one help document exists on this topic,
174
we get the actual help contents by calling QHelpEngineCore::fileData() and
175
display the document to the user.
176
177
\snippet doc_src_qthelp.cpp 6
178
179
For further information on how to use the API, have a look at
180
the QHelpEngine class reference.
181
182
\target qthelp-security-considerations
183
\section1 Security Considerations
184
185
A compressed help file is a database that can hold documents of any type,
186
and the help system processes those documents on behalf of the user. The
187
Qt Help module is not designed or hardened to handle malicious
188
content. Therefore, only register help files that come from a source that
189
you trust, such as your Qt installation or the vendor of an application
190
that you installed. Treat a .qch file that you download from the web,
191
receive by email, or find in a shared folder with the same caution as an
192
executable from the same source.
193
194
In particular, be aware of the following:
195
196
\list
197
\li A help file is opened as an SQLite database, and QHelpSearchEngine
198
indexes the documents in it for full text search as soon as the
199
file is registered, which is before any page from it is displayed.
200
\li The documents are rendered by whichever class your application
201
uses for that purpose, such as QTextBrowser. Such a renderer is
202
not hardened, and misses many of the security features of a modern
203
HTML5 renderer. It might therefore crash or misbehave for some
204
documents.
205
\li A help file can contain links that point outside the file, such as
206
\c http or \c mailto links. If your application passes such an
207
address to QDesktopServices::openUrl(), the operating system opens
208
it in the web browser or mail client of the user. Documentation
209
that appears to be local can therefore direct the user to any
210
address on the internet.
211
\li A help file can contain documents of a type that your application
212
cannot display itself. If your application writes such a document
213
to a temporary file and lets the operating system open it, the
214
help file determines which application is launched.
215
\endlist
216
217
The same considerations apply to the help collection file (.qhc), because
218
the collection file determines which help files are loaded.
219
*/
220
221
/*!
222
\page qthelpproject.html
223
\title Qt Help Project
224
225
A Qt help project collects all data necessary to generate a
226
compressed help file. Along with the actual help data, like
227
the table of contents, index keywords and help documents, it
228
contains some extra information like a namespace to identify
229
the help file. One help project stands for one documentation set,
230
for example the \l{qmake Manual}.
231
232
\section1 Qt Help Project File Format
233
234
The file format is XML-based. For a better understanding of
235
the format we will discuss the following example:
236
237
\snippet doc_src_qthelp.qdoc 7
238
239
\section2 Namespace
240
241
To enable the QHelpEngine to retrieve the proper documentation to
242
a given link, every documentation set has to have a unique
243
identifier. A unique identifier also makes it possible for the
244
help collection to keep track of a documentation set without relying
245
on its file name. The Qt help system uses a namespace as identifier
246
which is defined by the mandatory namespace tags. In the example
247
above, the namespace is "mycompany.com.myapplication.1.0".
248
249
\target Virtual Folders
250
\section2 Virtual Folders
251
252
Having a namespace for every documentation set naturally means that
253
the documentation sets are quite separated. From the help engine's
254
point of view, this is beneficial. However, from the writer's view
255
it is often desirable to cross reference certain topics from one
256
manual to another without having to specify absolute links. To
257
solve this problem, the help system introduced the concept of
258
virtual folders.
259
260
A virtual folder will become the root directory of all files
261
referenced in a compressed help file. When two documentation sets
262
share the same virtual folder, they can use relative paths when
263
defining hyperlinks pointing to each other. If a file is contained
264
in both documentation sets, the one from the current set has
265
precedence over the other.
266
267
\snippet doc_src_qthelp.qdoc 8
268
269
The above example specifies \e doc as virtual folder. If another
270
manual specifies the same folder, for example for a small helper
271
tool \e {My Application}, it is sufficient to write
272
\e {doc.html#section1} to reference the first section in the
273
\e {My Application} manual.
274
275
The virtual folder tag is mandatory and the folder name must not
276
contain any slashes (/).
277
278
\target Filter Section
279
\section2 Filter Section
280
281
A filter section contains the actual documentation. A Qt help project
282
file may contain more than one filter section. Every filter section
283
consists of the table of contents, the keywords, and the files list.
284
In theory all parts are optional but not specifying anything there will
285
result in an empty documentation set.
286
287
\section3 Table of Contents
288
289
\snippet doc_src_qthelp.qdoc 11
290
291
One section tag represents one item in the table of contents. The
292
sections can be nested to any degree, but from a user's perspective
293
it should not be more than four or five levels. A section is defined
294
by its title and reference. The reference, like all file references in a Qt
295
help project, are relative to the help project file itself.
296
\note The referenced files must be in the same directory as the help
297
project file (or in a subdirectory). An absolute file path is not supported
298
either.
299
300
\section3 Keywords
301
302
\snippet doc_src_qthelp.qdoc 12
303
304
The keyword section lists all keywords of this filter section. A
305
keyword consists basically of a name and a file reference. If the
306
attribute \e name is used, the keyword specified there will appear in the
307
visible index. That is, it will be accessible through the QHelpIndexModel
308
class. If \e id is used, the keyword does not appear in the index and is
309
only accessible via \l QHelpEngineCore::documentsForIdentifier(). \e name
310
and \e id can be specified at the same time.
311
312
\section3 Files
313
314
\snippet doc_src_qthelp.qdoc 13
315
316
Finally, the actual documentation files have to be listed. Make sure
317
that all files necessary to display the help are mentioned. That is,
318
stylesheets or similar files need to be listed as well. The files, like all
319
file references in a Qt help project, are relative to the help project file
320
itself. As the example shows, files (but not directories) can also be
321
specified as patterns using wildcards. All listed files will be compressed
322
and written to the Qt compressed help file. So, in the end, one single Qt
323
help file contains all documentation files along with the contents and
324
indices. \note The referenced files must be inside the same directory
325
as the help project file (or in a subdirectory). An absolute file path
326
is not supported either.
327
*/
qttools
src
assistant
help
doc
src
qthelp.qdoc
Generated on
for Qt by
1.16.1