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
assistant-manual.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
\page qtassistant-index.html
6
\title Qt Assistant Manual
7
\ingroup qttools
8
9
\startpage {Qt Reference Pages}
10
\nextpage Qt Assistant Quick Guide
11
12
\keyword Qt Assistant
13
14
\QA is a tool for viewing on-line documentation in Qt help file format.
15
For more information about basic \QA functions, see
16
\l{Qt Assistant Quick Guide}.
17
18
Qt installations include a set of reference and tools documentation that
19
you can view in the Qt Creator IDE and in \QA. You can add custom
20
documentation to the set of documents displayed in the \QA main view. For
21
detailed information about all \QA functions, see \l{Using Qt Assistant}.
22
23
\warning Only load and view help files that come from a source
24
that you trust. Viewing a help file from an untrusted source is a security
25
risk. For more information, see \l{Security Considerations}.
26
27
You can use \QA as the help viewer in your applications. You can display
28
your own documentation and customize \QA to look and feel like part of your
29
application. You can change the window title or icon, as well as menu texts
30
and actions. For more information, see \l{Customizing Qt Assistant}.
31
32
\section1 Table of Contents
33
34
\list
35
\li \l{Qt Assistant Quick Guide}
36
\li \l{Using Qt Assistant}
37
\li \l{Customizing Qt Assistant}
38
\li \l{Licenses and Attributions}
39
\endlist
40
*/
41
42
/*!
43
\page assistant-custom-help-viewer.html
44
\title Customizing Qt Assistant
45
46
\previouspage Using Qt Assistant
47
\nextpage Licenses and Attributions
48
49
Using \QA as custom help viewer requires more than just being able to
50
display custom documentation. It is equally important that the
51
appearance of \QA can be customized so that it is seen as a
52
application-specific help viewer rather than \QA. This is achieved by
53
changing the window title or icon, as well as some application-specific
54
menu texts and actions. For a complete list of possible customizations,
55
see \l{Creating a Custom Help Collection File}.
56
57
Another requirement of a custom help viewer is the ability to receive
58
actions or commands from the application it provides help for. This is
59
especially important when the application offers context sensitive help.
60
When used in this way, the help viewer may need to change its contents
61
depending on the state the application is currently in. This means that
62
the application has to communicate the current state to the help viewer.
63
For more information, see \l{Using Qt Assistant Remotely}.
64
65
The \l{Simple Text Viewer Example}{Simple Text Viewer} example uses the
66
techniques described in this document to show how to use \QA as a custom
67
help viewer for an application.
68
69
\warning In order to ship Qt Assistant in your application, it is crucial
70
that you include the sqlite plugin. For more information on how to include
71
plugins in your application, refer to the \l{Deploying Qt Applications}
72
{deployment documentation}.
73
74
\section1 Qt Help Collection Files
75
76
The first important point to know about \QA is that it stores all
77
settings related to its appearance \e and a list of installed
78
documentation in a help collection file. This means, when starting \QA
79
with different collection files, \QA may look totally different. This
80
complete separation of settings makes it possible to deploy \QA as a
81
custom help viewer for more than one application on one machine
82
without risk of interference between different instances of \QA.
83
84
To apply a certain help collection to \QA, specify the respective
85
collection file on the command line when starting it. For example:
86
87
\snippet doc_src_assistant-manual.qdoc 8
88
89
However, storing all settings in one collection file raises some problems.
90
The collection file is usually installed in the same directory as the
91
application itself, or one of its subdirectories. Depending on the
92
directory and the operating system, the user may not have any permissions
93
to modify this file which would happen when the user settings are stored.
94
Also, it may not even be possible to give the user write permissions, for
95
example when the file is located on a read-only medium like a CD-ROM.
96
97
Even if it is possible to give everybody the right to store their settings
98
in a globally available collection file, the settings from one user would
99
be overwritten by another user when exiting \QA.
100
101
To solve this dilemma, \QA creates user specific collection files which
102
are more or less copied from the original collection file. The user-specific
103
collection file will be saved in a subdirectory of the path returned by
104
QDesktopServices::AppDataLocation. The subdirectory, or \e{cache directory}
105
within this user-specific location, can be defined in the help collection
106
project file. For example:
107
108
\snippet doc_src_assistant-manual.qdoc 7
109
110
So, when calling
111
112
\snippet doc_src_assistant-manual.qdoc 8
113
114
\QA actually uses the collection file:
115
116
\snippet doc_src_assistant-manual.qdoc 9
117
118
There is no need ever to start \QA with the user specific collection
119
file. Instead, the collection file shipped with the application should
120
always be used. Also, when adding or removing documentation from the
121
collection file (see next section) always use the normal collection file.
122
\QA will take care of synchronizing the user collection files when the
123
list of installed documentation has changed.
124
125
\section1 Displaying Custom Documentation
126
127
Before \QA is able to show documentation, it has to know where it can
128
find the actual documentation files, meaning that it has to know the
129
location of the Qt compressed help file (*.qch). As already mentioned,
130
\QA stores references to the compressed help files in the currently used
131
collection file. So, when creating a new collection file you can list
132
all compressed help files \QA should display.
133
134
\snippet doc_src_assistant-manual.qdoc 5
135
136
Sometimes, depending on the application for which \QA acts as a
137
help viewer, more documentation needs to be added over time; for
138
example, when installing more application components or plugins.
139
This can be done manually in \QA by selecting \gui Edit > \gui Preferences
140
> \gui Documentation. However, this approach has the disadvantage
141
that every user has to do it manually to get access to the new
142
documentation.
143
144
The preferred way of adding documentation to an already existing collection
145
file is to use the \c{-register} command line flag of \QA. When starting
146
\QA with this flag, the documentation will be added and \QA will
147
exit right away displaying a message if the registration was successful
148
or not.
149
150
\warning Only register compressed help files (.qch) that come from a
151
source that you trust. Registering and viewing a help file from an
152
untrusted source is a security risk. For more information, see
153
\l{Security Considerations}.
154
155
The search indexing will only index your custom *.html, *.htm,
156
and *.txt files.
157
158
\snippet doc_src_assistant-manual.qdoc 6
159
160
The \c{-quiet} flag can be passed on to \QA to prevent it from writing
161
out the status message.
162
163
\note \QA shows the documentation in the \gui Contents view in the same
164
order as it was registered.
165
166
167
\section1 Changing the Appearance of Qt Assistant
168
169
The appearance of \QA can be changed by passing different command line options
170
on startup. However, these command line options only allow to show or hide
171
specific widgets, like the contents or index view. Other customizations, such
172
as changing the application title or icon, or disabling the filter functionality,
173
can be done by creating a custom help collection file.
174
175
\section2 Creating a Custom Help Collection File
176
177
The help collection file (*.qhc) used by \QA is created when running the
178
\c qhelpgenerator tool on a help collection project file (*.qhcp).
179
The project file format is XML and it supports the following tags:
180
181
\table
182
\header
183
\li Tag
184
\li Brief Description
185
\row
186
\li \c{<title>}
187
\li Specifies a window title for \QA.
188
\row
189
\li \c{<homePage>}
190
\li Specifies the page to display when selecting \gui Home in the
191
\QA main window.
192
\row
193
\li \c{<startPage>}
194
\li Specifies the page to display initially when the help collection
195
is used.
196
\row
197
\li \c{<currentFilter>}
198
\li Specifies the filter that is initially used.
199
If this filter is not specified, the documentation will not be filtered. This has
200
no impact if only one documentation set is installed.
201
\row
202
\li \c{<applicationIcon>}
203
\li Describes an icon that will be used instead of the normal \QA
204
application icon. This is specified as a relative path from the directory
205
containing the collection file.
206
\row
207
\li \c{<enableFilterFunctionality>}
208
\li Enables or disables user accessible filter functionality,
209
making it possible to prevent the user from changing any filter when running \QA.
210
It does not mean that the internal filter functionality is completely disabled.
211
Set the value to \c{false} if you want to disable the filtering. If the filter
212
toolbar should be shown by default, set the attribute \c{visible} to \c{true}.
213
\row
214
\li \c{<enableDocumentationManager>}
215
\li Shows or hides the \gui Documentation tab in the \gui Preferences
216
dialog. Disabling the \gui Documentation tab allows you to limit
217
\QA to display a specific documentation set or make it impossible for the end user
218
to accidentally remove or install documentation. To hide the \gui Documentation tab,
219
set the tag value to \c{false}.
220
\row
221
\li \c{<enableAddressBar>}
222
\li Enables or disables the address bar functionality. By default it
223
is enabled. To disable it, set the tag value to \c{false}. If the
224
address bar functionality is enabled, the address bar can be shown by setting the
225
tag attribute \c{visible} to \c{true}.
226
\row
227
\li \c{<aboutMenuText>, <text>}
228
\li Lists localized versions for the \gui About menu item in the
229
\gui Help menu. For example, \gui {About Application}. The text is
230
specified within the \c{text} tags. The \c{language} attribute takes the two
231
letter language name. The text is used as the default text if no language
232
attribute is specified.
233
\row
234
\li \c{<aboutDialog>, <file>, <icon>}
235
\li Specifies the text for the \gui About dialog that can be opened
236
from the \gui Help menu. The text is taken from the
237
file in the \c{file} tags. It is possible to specify a different file or any
238
language. The icon defined by the \c{icon} tags is applied to any language.
239
\row
240
\li \c{<cacheDirectory>, <cacheDirectory base="collection">}
241
\li Specifies the cache directory that is used to store index files
242
needed for the full text search and a copy of the collection file.
243
The copy is needed because \QA stores all its settings in the
244
collection file, and therefore, it must be writable for the user.
245
The directory is specified as a relative path.
246
If the \c{base} attribute is set to "collection", the path is
247
relative to the directory the collection file resides in.
248
If the attribute is set to "default" or if it is missing,
249
the path is relative to the directory given by
250
QDesktopServices::AppDataLocation. The first form is useful for
251
collections that are used in a \e mobile way, such as carried around
252
on a USB stick.
253
\row
254
\li \c{<enableFullTextSearchFallback>}
255
\li Enables or disables the ability to fallback and use the full text
256
search if a keyword cannot be found in the index. This functionality
257
can be used while remote controlling \QA. To make it available for
258
remote control, set the tag value to \c{true}.
259
\endtable
260
261
In addition to those \QA specific tags, the tags for generating and registering
262
documentation can be used. See \l{Qt Help Collection Files} documentation for more information.
263
264
An example of a help collection file that uses all the available tags is shown below:
265
266
\snippet doc_src_assistant-manual.qdoc 1
267
268
To create the binary collection file, run the \c qhelpgenerator tool:
269
270
\snippet doc_src_assistant-manual.qdoc 10
271
272
To test the generated collection file, start \QA in the following way:
273
274
\snippet doc_src_assistant-manual.qdoc 8
275
276
\section1 Using Qt Assistant Remotely
277
278
Even though the help viewer is a standalone application, it will mostly
279
be launched by the application it provides help for. This approach
280
gives the application the possibility to ask for specific help contents
281
to be displayed as soon as the help viewer is started. Another advantage
282
with this approach is that the application can communicate with the
283
help viewer process and can therefore request other help contents to be
284
shown depending on the current state of the application.
285
286
So, to use \QA as the custom help viewer of your application, simply
287
create a QProcess and specify the path to the \QA executable. In order
288
to make \QA listen to your application, turn on its remote control
289
functionality by passing the \c{-enableRemoteControl} command line option.
290
291
The following example shows how this can be done:
292
293
\snippet doc_src_assistant-manual.qdoc 2
294
295
Once \QA is running, you can send commands by using the stdin channel of
296
the process. The code snippet below shows how to tell \QA to show a certain
297
page in the documentation.
298
299
\snippet doc_src_assistant-manual.qdoc 3
300
301
\note The trailing newline character is required to mark the end
302
of the input.
303
304
The following commands can be used to control \QA:
305
306
\table
307
\header
308
\li Command
309
\li Brief Description
310
\row
311
\li \c{show <Widget>}
312
\li Shows the sidebar window (dock widget) specified by <Widget>. If the widget
313
is already shown and this command is sent again, the widget will be
314
activated, meaning that it will be raised and given the input focus.
315
Possible values for <Widget> are "contents", "index", "bookmarks" or "search".
316
\row
317
\li \c{hide <Widget>}
318
\li Hides the dock widget specified by <Widget>. Possible values for
319
<Widget> are "contents", "index", "bookmarks" and "search".
320
\row
321
\li \c{setSource <Url>}
322
\li Displays the given <Url>. The URL can be absolute or relative
323
to the currently displayed page. If the URL is absolute, it has to
324
be a valid Qt help system URL. That is, starting with "qthelp://".
325
\row
326
\li \c{activateKeyword <Keyword>}
327
\li Inserts the specified <Keyword> into the line edit of the
328
index dock widget and activates the corresponding item in the
329
index list. If such an item has more than one link associated
330
with it, a topic chooser will be shown.
331
\row
332
\li \c{activateIdentifier <Id>}
333
\li Displays the help contents for the given <Id>. An ID is unique
334
in each namespace and has only one link associated to it, so the
335
topic chooser will never pop up.
336
\row
337
\li \c{syncContents}
338
\li Selects the item in the contents widget which corresponds to
339
the currently displayed page.
340
\row
341
\li \c{setCurrentFilter <filter>}
342
\li Selects the specified filter and updates the visual representation
343
accordingly.
344
\row
345
\li \c{expandToc <Depth>}
346
\li Expands the table of contents tree to the given depth. If depth
347
is 0, the tree will be collapsed completely. If depth is -1,
348
the tree will be expanded completely.
349
\row
350
\li \c{register <help file>}
351
\li Adds the given Qt compressed help file to the collection.
352
\row
353
\li \c{unregister <help file>}
354
\li Removes the given Qt compressed help file from the collection.
355
\endtable
356
357
If you want to send several commands within a short period of time, it is
358
recommended that you write only a single line to the stdin of the process
359
instead of one line for every command. The commands have to be separated by
360
a semicolon, as shown in the following example:
361
362
\snippet doc_src_assistant-manual.qdoc 4
363
*/
364
365
/*
366
\section2 Modifying \QA with Command Line Options
367
368
Different help collections can be shown by simply passing the help collection
369
path to \QA. For example:
370
371
\snippet doc_src_assistant-manual.qdoc 0
372
373
Other available options the can be passed on the command line.
374
375
\table
376
\header
377
\li Command Line Option
378
\li Brief Description
379
\row
380
\li -collectionFile <file.qhc>
381
\li Uses the specified collection file instead of the default one.
382
\row
383
\li -showUrl URL
384
\li Shows the document referenced by URL.
385
\row
386
\li -enableRemoteControl
387
\li Enables \QA to be remotly controlled.
388
\row
389
\li -show <widget>
390
\li Shows the specified dockwidget which can be "contents", "index",
391
"bookmarks" or "search".
392
\row
393
\li -hide <widget>
394
\li Hides the specified dockwidget which can be "contents", "index",
395
"bookmarks" or "search.
396
\row
397
\li -activate <widget>
398
\li Activates the specified dockwidget which can be "contents",
399
"index", "bookmarks" or "search.
400
\row
401
\li -register <doc.qch>
402
\li Registers the specified compressed help file in the given help
403
collection.
404
\row
405
\li -unregister <doc.qch>
406
\li Unregisters the specified compressed help file from the given
407
collection file.
408
\row
409
\li -quiet
410
\li Doesn't show any error, warning or success messages.
411
\endtable
412
*/
413
414
/*!
415
\page assistant-licenses.html
416
\title Licenses and Attributions
417
418
\previouspage Customizing Qt Assistant
419
420
\QA is available under commercial licenses from \l{The Qt Company}. In
421
addition, it is available under the \l{GNU General Public License, version 3}.
422
423
Furthermore, \QA \QtVersion may contain third party modules
424
under following permissive licenses:
425
426
\annotatedlist attributions-qtassistant-tools
427
*/
qttools
src
assistant
assistant
doc
src
assistant-manual.qdoc
Generated on
for Qt by
1.16.1