PDA

View Full Version : QHelpEngine does not display images



laura7s
20th November 2015, 16:56
Hello all,

I'm using a QHelpEngine to display my help files (html files) in my custom QTextBrowser. I have generated my help.qch and help.qhc files correctly (I presume) since I verified it using the assistant: assistant -collectionFile help.qhc and indeed my html page was displayed as expected including the .gif image that was present in the html page.

Now I'm trying to display the same content in my application and again I can display the html file but now my image is lost and is replaced with the image_broken_icon.

In short, my implementation of QHelpEngine with QTextBrowser does not display the images that are present in the html files that I'm loading in the qtextbrowser.
Any insights would be greatly appreciated!

This is the part of the code where I load the html file:


void HelpBrowser::setSource(const QUrl &url) {
if (helpEngine != 0) {
QByteArray helpData = helpEngine->fileData(url);
// show the documentation to the user
if (!helpData.isEmpty()) {
setHtml(QLatin1String(helpData));
}

int anchorPos = url.toString().indexOf(QChar('#'));
if (anchorPos >= 0){
QString anchor = url.toString().mid(anchorPos+1);
scrollToAnchor(anchor);
}
}
}

Thank you for your help,
Laura

ChrisW67
21st November 2015, 20:08
Have you deployed the Qt gif image plugin with your application?

laura7s
23rd November 2015, 14:47
Hello again,

Thanks for the suggestion! I checked this by trying to load a .gif image at another part of my application and it worked fine. So that wasn't the problem. I then used process monitor (windows) and tried to see where my application is trying to load the image files from. Apparently, I had misunderstood that my image file is also part of the help.qch file. That's not the case. I could load my html files correctly when I placed my images folder in the directory of the executable.

Best,
Laura