View Full Version : QWebView - scaling issues with .svg

17th September 2015, 14:25
Hello there!

I've recently ported a help widget that displays a .qch file from QTextBrowser to QWebView (i did this mainly for performance - the asynchronous loading of QWebView was why i was switching).

To my dismay i had to notice that the help pages look very different now, some of the svg graphics are much smaller now. Upon further inspection i found out that the images that look too small have been saved like this:
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="79.375mm" height="88.1944mm" style="..." viewBox="0 0 79.375 88.1944"
while the svg files that are still shown correctly look like this:
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="225px" height="250px" style="..." viewBox="0 0 225 250"

Instead of changing lots and lots of svg files (which i really don't have much control over anyways) i'm wondering what needs to be tweaked in QWebView to deal with this correctly.
If i have a look at the assistant.exe (vanilla Qt 5.3.1) which also uses QWebView to show the same files, it looks fine there. i have not found anything in the source code of assistant that would explain why it works there, but not with my own class.

Another difference that i found was that the svgs that are shown in my app are pixelated, while when i look at them in the assistant, they are always crisp, even when i'm zooming in.

What am i missing here? Is there some image cache somewhere that i need to configure?

Thanks for any pointers,

17th September 2015, 17:11
solved this myself, in my HelpNetworkAccessManager that i used to access the help file, i wasn't specifying the correct mime-type in the network replies. Seems without the type, the handling of svg images is very awkward (i'm dumbfounded that it works at all!)