helpbrowser.cpp Example File
contextsensitivehelp/helpbrowser.cpp 
          
            
            
#include <QtCore/QLibraryInfo>
#include <QtWidgets/QApplication>
#include <QtHelp/QHelpEngineCore>
#include "helpbrowser.h"
HelpBrowser::HelpBrowser(QWidget *parent)
    : QTextBrowser(parent)
{
    QString collectionFile = QLibraryInfo::location(QLibraryInfo::ExamplesPath)
        + QLatin1String("/help/contextsensitivehelp/docs/wateringmachine.qhc");
    m_helpEngine = new QHelpEngineCore(collectionFile, this);
    if (!m_helpEngine->setupData()) {
        delete m_helpEngine;
        m_helpEngine = 0;
    }
}
void HelpBrowser::showHelpForKeyword(const QString &id)
{
    if (m_helpEngine) {
        QMap<QString, QUrl> links = m_helpEngine->linksForIdentifier(id);
        if (links.count())
            setSource(links.constBegin().value());
    }
}
QVariant HelpBrowser::loadResource(int type, const QUrl &name)
{
    QByteArray ba;
    if (type < 4 && m_helpEngine) {
        QUrl url(name);
        if (name.isRelative())
            url = source().resolved(url);
        ba = m_helpEngine->fileData(url);
    }
    return ba;
}