PDA

View Full Version : Using QWebView together with QHelpEngine



JPNaude
23rd September 2010, 16:44
Hi

I've been struggling with this for days now. I generated help using Doxygen 1.7.1 which produces a website and a .qhc file.

I am able to load the .qhc file using QTextBrowser and it loads fine, but QTextBrowser does not seem to support everything that is in the output, not sure if it is in the style sheet or in the javascript. I can view the file in QTextBrowser either by doing it as described in the good old "Using QtHelp to Lend a Helping Hand" Qt Quarterly article or by showing it directly using QTextBrowser::setSource().

Since it seems like QTextBrowser is not able to display the page correctly, I turned to QWebView which shows it beautifully when loading the website directly using QWebView::setUrl(). However I need to use QHelpContentWidget for the indexing of the help file's content.

Thus I do the following:



// Set up the help engine:
helpEngine = new HelpEngine("D:/doxygen_output/my_help.qhc", this);
helpEngine->setupData();

// Create a help content widget:
QHelpContentWidget* content_widget = new QHelpContentWidget();
connect(content_widget,SIGNAL(linkActivated(const QUrl&)),SLOT(updateUrl(QUrl)));

// Create the webview:
webView = new QWebView();
webView ->show();

// webView and helpEngine are declared in the same class as the slot, thus the slot implementation has access to it.


In my updateUrl() slot I then do the following:


void MyClass::updateUrl(const QUrl& url) {
webView->setHtml(helpEngine->fileData(url),"D:/doxygen_output/");
}


The above code works perfectly, however it misses the point of providing the help in only two files: .qhc and .qch.

Thus my problem is: How can I let QWebView know that it should use a baseUrl which is a virtual folder in the helpEngine? Is this even possible at all?

I've also tried the following but this does not work:


void MyClass::updateUrl(const QUrl& url) {
QString relative_url = url.toString();
QStringList item_list = relative_url.split("/");
item_list.pop_back();
QString path_url = item_list.join("/");
path_url.append("/");
// At this stage path_url is: "qthelp://documentation_namespace/virtual_folder/"
webView->setHtml(helpEngine->fileData(url),path_url);
}


Thank you,
Jaco

timohare
8th June 2011, 03:51
Hi Jaco,
Did you ever manage to fix this problem?

Woody89
7th May 2012, 11:26
I think I'm going to bring this topic back to life.

I have almost the same problem, but here the css isn't showing up. I tried to give a virtual path (QUrl("qthelp://com.mynaspace/doc")) and a existing path (QUrl("C:/MyApplication/doc")). None of them seem to be working.

Any help would be welcome.