Qt help file distribution



  • Hi all,
    My application has integrated help implemented with QHelpEngine and QTextBrowser. I have created both compressed help file and collection file and everything seems to be working on my PC. But when I try to build and run my app on another PC I receiver the error "QTextBrowser: No document for qthelp.//...". I put the compressed help file and collection file in the same folder with app binary.

    So my question are: should I make some additional steps concerning help files during the program installation (e.g. register compressed help file)? Is this possible to include help file in the resource file? Are any good examples for creating Windows installers, Linux binary packages (e.g. deb and rpm) for the programs which include Qt help files?

    P.S. I am using Qt 5.6.1 shipped with Ubuntu 16.10.

    Thanks in advance!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you show the code you are using to load the file ?



  • The two classes HelpBrowser and HelpWidget are responsible for displaying the help content.

    HelpWidget is following:

    class HelpWidget : public QSplitter
    {
        Q_OBJECT
      public:
            HelpWidget(QWidget *parent = 0);
    
       private:
            QHelpEngine* help_engine_;
            HelpBrowser *help_browser_;
            QTabWidget* tab_widget_;
    
            void connectSignalsAndSlots();
            void setupTabWidget();
            void insertWidgets();
     };
    
    HelpWidget::HelpWidget(QWidget *parent) : QSplitter(Qt::Horizontal, parent),
        help_engine_(new QHelpEngine("my_manual.qhc", this)),
        help_browser_(new HelpBrowser(help_engine_, this)),
        tab_widget_(new QTabWidget(this))
    {
        help_engine_->setupData();
        setupTabWidget();
        help_browser_->setSource(QUrl("qthelp://mycompany.myapp.1.0/app/app_manual.html"));
        connectSignalsAndSlots();
        insertWidgets();
    }
    
    void HelpWidget::connectSignalsAndSlots()
    {
        connect(help_engine_->contentWidget(), SIGNAL(linkActivated(QUrl)), 
                        help_browser_, SLOT(setSource(QUrl)));
        connect(help_engine_->indexWidget(), SIGNAL(linkActivated(QUrl, QString)), 
                        help_browser_, SLOT(setSource(QUrl)));
    }
    
    void HelpWidget::setupTabWidget()
    {
        tab_widget_->setMaximumWidth(200);
        tab_widget_->addTab(help_engine_->contentWidget(), tr("Contents"));
        tab_widget_->addTab(help_engine_->indexWidget(), tr("Index"));
    }
    
    void HelpWidget::insertWidgets()
    {
        insertWidget(0, tab_widget_);
        insertWidget(1, help_browser_);
    }
    
    

    And HelpBrowser:

    class HelpBrowser : public QTextBrowser
    {            
      public:
            HelpBrowser(QHelpEngine* helpEngine, QWidget* parent = 0){}
            QVariant loadResource (int type, const QUrl& name);
            virtual ~HelpBrowser() {}
      private:
            QHelpEngine* help_engine_;
    };
    
    QVariant HelpBrowser::loadResource(int type, const QUrl &name)
    {
        if (name.scheme() == "qthelp")
            return QVariant(help_engine_->fileData(name));
        else
            return QTextBrowser::loadResource(type, name);
    }
    
    

  • Lifetime Qt Champion

    You should always use fullpaths when dealing with external files like that. The working directory might not be what you expect it to be when your application is run.

    As for deploying the help files. Depending on its size your can use Qt's resources so it's embedded in there.

    Otherwise it depends on your target platform. You can use Qt's installer framework to build an installer that can work cross-platform.

    If you'd rather provide packages for specific linux distributions, then you should follow these distribution packaging documentation.


Log in to reply