Unable to get a custom helpfile to work from inside a Qt Application using Qt Assistant

632 Views Asked by At

I am trying to learn how to use Qt Assistant for displaying a custom help in an application.

I found an example on Qt site:

http://qt-project.org/doc/qt-4.7/help-simpletextviewer.html

(using Qt 4.7.3)

All the source files needed are at the site above. I created html and png files and placed them in a "help" folder inside the project folder.

Running Qt Assistant from command line works great.

Loading the help file in the Assistant also works. What I can't get to do is to load the start page in the help file, as explained in this section: http://qt-project.org/doc/qt-4.7/assistant-custom-help-viewer.html#id-0c628592-dd04-4465-94b1-e5d4a91d7cd4

void Assistant::showDocumentation(const QString &page)
 {
    if (!startAssistant())
        return;

    QByteArray ba("SetSource ");
    ba.append("qthelp://com.trolltech.examples.simpletextviewer/doc/");

    proc->write(ba + page.toLocal8Bit() + '\n');
}

With the detailed explanation of SetSource showing

    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://".

I don't have a web page... but i tried to display the index from the local set of files, and i always get a 404 error saying "cannot load page blahblah/help/index.html"

How can I create a local path as they say, or how can I create a "valid Qt help system URL" ?``

Note: SetSource and setSource have exactly the same results... and documentation and their own examples use them both... are these options not case sensitive ?

I answered my own question with a solution that doesn't seem right though... I would appreciate a better answer.

1

There are 1 best solutions below

0
On BEST ANSWER

There must be something wrong with either my solution or the documentation...

I was able to get the page to display by changing an option...

replace QByteArray ba("SetSource ");

with QByteArray ba("Set Source ");