Home > Articles > Programming > C/C++

  • Print
  • + Share This
This chapter is from the book

Using Qt Assistant for Powerful Online Help

Qt Assistant is a redistributable online help application supplied by Trolltech. Its main virtues are that it supports indexing and full text search and that it can handle documentation sets for multiple applications. To make use of Qt Assistant, we must incorporate the necessary code in our application, and we must make Qt Assistant aware of our documentation. [*]

Communication between a Qt application and Qt Assistant is handled by the QAssistantClient class, which is located in a separate library. To link this library with an application, we must add this line to the application's .pro file:

CONFIG += assistant

We will now review the code of a new HelpBrowser class that uses Qt Assistant.

class HelpBrowser
    static void showPage(const QString &page);

    static QDir directoryOf(const QString &subdir);

    static QAssistantClient *assistant;

Here's the new showPage() implementation:

QAssistantClient *HelpBrowser::assistant = 0;

void HelpBrowser::showPage(const QString &page)
    QString path = directoryOf("doc").absoluteFilePath(page);
    if (!assistant)
         assistant = new QAssistantClient("");

The QAssistantClient constructor accepts a path string as its first argument, which it uses to locate the Qt Assistant executable. By passing an empty path, we signify that QAssistantClient should look for the executable in the PATH environment variable. QAssistantClient has a showPage() function that accepts a page name with an optional HTML anchor.

The next step is to prepare a table of contents and an index for the documentation. This is done by creating a Qt Assistant profile and writing a .dcf file that provides information about the documentation. All this is explained in Qt Assistant's online documentation, so we will not duplicate that information here.

An alternative to using a web browser, QTextBrowser, or Qt Assistant is to use platform-specific approaches to providing online help. For Windows applications, it might be desirable to create Windows HTML Help files and to provide access to them using Microsoft Internet Explorer. You could use Qt's QProcess class or the ActiveQt framework for this. On Mac OS X, Apple Help provides similar functionality to Qt Assistant.

We have now reached the end of Part II. The chapters that follow in Part III cover more advanced and specialized features of Qt. The C++ and Qt code they present are no more difficult than the code we have presented in Part II, but some of the concepts and ideas may be more challenging in those areas that are new to you.

  • + Share This
  • 🔖 Save To Your Account