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