Using Qt Assistant as a Custom Help Viewer |
Tag | Brief Description |
---|---|
<title> | This property is used to specify a window title for Qt Assistant. |
<homePage> | This tag specifies which page should be display when pressing the home button in Qt Assistant's main user interface. |
<startPage> | This tag specifies which page Qt Assistant should initially display when the help collection is used. |
<currentFilter> | This tag specifies the filter that is initially used. If this filter is not specified, the documentation will not be filtered. This has no impact if only one documentation set is installed. |
<applicationIcon> | This tag describes an icon that will be used instead of the normal Qt Assistant application icon. This is specified as a relative path from the directory containing the collection file. |
<enableFilterFunctionality> | This tag is used to enable or disable user accessible filter functionality, making it possible to prevent the user from changing any filter when running Qt Assistant. It does not mean that the internal filter functionality is completely disabled. Set the value to false if you want to disable the filtering. If the filter toolbar should be shown by default, set the attribute visible to true. |
<enableDocumentationManager> | This tag is used to specify whether the documentation manager should be shown in the preferences dialog. Disabling the Documentation Manager allows you to limit Qt Assistant to display a specific documentation set or make it impossible for the end user to accidentally remove or install documentation. To hide the documentation manager, set the tag value to false. |
<enableAddressBar> | This tag describes if the address bar can be shown. By default it is enabled; if you want to disable it set the tag value to false. If the address bar functionality is enabled, the address bar can be shown by setting the tag attribute visible to true. |
<aboutMenuText>, <text> | The aboutMenuText tag lists texts for different languages which will later appear in the Help menu; e.g., "About Application". A text is specified within the text tags; the language attribute takes the two letter language name. The text is used as the default text if no language attribute is specified. |
<aboutDialog>, <file>, <icon> | The aboutDialog tag can be used to specify the text for the About dialog that can be opened from the Help menu. The text is taken from the file in the file tags. It is possible to specify a different file or any language. The icon defined by the icon tags is applied to any language. |
<cacheDirectory> | Specified as a path relative to the directory given by QDesktopServices::DataLocation, the cache path is used to store index files needed for the full text search and a copy of the collection file. The copy is needed because Qt Assistant stores all its settings in the collection file; i.e., it must be writable for the user. |
In addition to those Qt Assistant specific tags, the tags for generating and registering documentation can be used. See Qt Help Collection documentation for more information.
An example of a help collection file that uses all the available tags is shown below:
<?xml version="1.0" encoding="utf-8" ?> <QHelpCollectionProject version="1.0"> <assistant> <title>My Application Help</title> <startPage>qthelp://com.mycompany.1_0_0/doc/index.html</startPage> <currentFilter>myfilter</currentFilter> <applicationIcon>application.png</applicationIcon> <enableFilterFunctionality>false</enableFilterFunctionality> <enableDocumentationManager>false</enableDocumentationManager> <enableAddressBar visible="true">true</enableAddressBar> <cacheDirectory>mycompany/myapplication</cacheDirectory> <aboutMenuText> <text>About My Application</text> <text language="de">ber meine Applikation...</text> </aboutMenuText> <aboutDialog> <file>about.txt</file> <file language="de">ueber.txt</file> <icon>about.png</icon> </aboutDialog> </assistant> <docFiles> <generate> <file> <input>myapplication-manual.qhp</input> <output>myapplication-manual.qch</output> </file> </generate> <register> <file>myapplication-manual.qch</file> </register> </docFiles> </QHelpCollectionProject>
To create the binary collection file, run the qcollectiongenerator tool:
qcollectiongenerator mycollection.qhcp -o mycollection.qhc
To test the generated collection file, start Qt Assistant in the following way:
assistant -collectionFile mycollection.qhc
Even though the help viewer is a standalone application, it will mostly be launched by the application it provides help for. This approach gives the application the possibility to ask for specific help contents to be displayed as soon as the help viewer is started. Another advantage with this approach is that the application can communicate with the help viewer process and can therefore request other help contents to be shown depending on the current state of the application.
So, to use Qt Assistant as the custom help viewer of your application, simply create a QProcess and specify the path to the Assistant executable. In order to make Assistant listen to your application, turn on its remote control functionality by passing the -enableRemoteControl command line option.
Warning: The trailing '\0' must be appended separately to the QByteArray, e.g., QByteArray("command" + '\0').
The following example shows how this can be done:
QProcess *process = new QProcess; QStringList args; args << QLatin1String("-collectionFile") << QLatin1String("mycollection.qhc") << QLatin1String("-enableRemoteControl"); process->start(QLatin1String("assistant"), args); if (!process->waitForStarted()) return;
Once Qt Assistant is running, you can send commands by using the stdin channel of the process. The code snippet below shows how to tell Qt Assistant to show a certain page in the documentation.
QByteArray ba; ba.append("setSource qthelp://com.mycompany.1_0_0/doc/index.html"); ba.append('\0'); process->write(ba);
The following commands can be used to control Qt Assistant:
Command | Brief Description |
---|---|
show <Widget> | Shows the dock widget specified by <Widget>. If the widget is already shown and this command is sent again, the widget will be activated, meaning that it will be raised and given the input focus. Possible values for <Widget> are "contents", "index", "bookmarks" or "search". |
hide <Widget> | Hides the dock widget specified by <Widget>. Possible values for <Widget> are "contents", "index", "bookmarks" and "search". |
setSource <Url> | Displays the given <Url>. The URL can be absolute or relative to the currently displayed page. If the URL is absolute, it has to be a valid Qt help system URL; i.e., starting with "qthelp://". |
activateKeyword <Keyword> | Inserts the specified <Keyword> into the line edit of the index dock widget and activates the corresponding item in the index list. If such an item has more than one link associated with it, a topic chooser will be shown. |
activateIdentifier <Id> | Displays the help contents for the given <Id>. An ID is unique in each namespace and has only one link associated to it, so the topic chooser will never pop up. |
syncContents | Selects the item in the contents widget which corresponds to the currently displayed page. |
setCurrentFilter | Selects the specified filter and updates the visual representation accordingly. |
expandToc <Depth> | Expands the table of contents tree to the given depth. If depth is less than 1, the tree will be collapsed completely. |
If you want to send several commands within a short period of time, it is recommended that you write only a single line to the stdin of the process instead of one line for every command. The commands have to be separated by a semicolon, as shown in the following example:
QByteArray ba; ba.append("hide bookmarks;"); ba.append("hide index;"); ba.append("setSource qthelp://com.mycompany.1_0_0/doc/index.html"); ba.append('\0'); process->write(ba);
In older versions of Qt, the help system was based on Document Content File (DCF) and Qt Assistant Documentation Profile (ADP) formats. In contrast, Qt Assistant and the help system used in Qt 4.4 use the formats described earlier in this manual.
Unfortunately, the old file formats are not compatible with the new ones. In general, the differences are not that big — in most cases is the old format is just a subset of the new one. One example is the namespace tag in the Qt Help Project format, which was not part of the old format, but plays a vital role in the new one. To help you to move to the new file format, we have created a conversion wizard.
The wizard is started by executing qhelpconverter. It guides you through the conversion of different parts of the file and generates a new qch or qhcp file.
Once the wizard is finished and the files created, run the qhelpgenerator or the qcollectiongenerator tool to generate the binary help files used by Qt Assistant.
[Previous: Qt Assistant in More Detail] [Contents]
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.6 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com