[Qt-interest] QWebView local image problem

Strahinja Markovic strahinja.markovic at gmail.com
Thu Dec 24 17:23:54 CET 2009


Dominic Stalder wrote:

> Hi
> 
> I can't find my old post, so sorry if I double post ;-)
> 
> I want to show my qhelp via the QWebView, at this time it works like this:
> 
>     // gets the byte array of the online help
>     QByteArray help = helpEngine->fileData(url);
>    
>     // sets the content of the help browser based on the given url
>     helpBrowser->setContent(help, QString("text/html"), url);
> 
> The url looks like this qthelp://ch.bfh.wiitetris/doc/onlinehilfe.html
> 
> This works, but now I can't see any images. The images are in a special
> folder in the /doc directory (the same place as onlinehilfe.html is
> located). The images are referenced as follow: <img
> src="figures/menu_game.png" alt="PIC">
> 
> Has anybody some tips?
> 
> Regards
> Dominic

You need to specify a correct baseUrl. So if your images are referenced with 
"figures/menu_game.png", and the path to the "figures" folder is 
"qthelp://ch.bfh.wiitetris/doc/figures/", then your baseUrl should be 
"qthelp://ch.bfh.wiitetris/doc/". That way when webkit looks for 
"figures/menu_game.png", it will prepend "qthelp://ch.bfh.wiitetris/doc/" 
and load "qthelp://ch.bfh.wiitetris/doc/figures/menu_game.png".

Hope that helps.

Sincerely,

Strahinja Markovic



More information about the Qt-interest-old mailing list