[PyQt] PyQt, QWebView, SVG Rendering Problem
David Boddie
david at boddie.org.uk
Sat Jan 24 00:25:27 GMT 2009
On Fri Jan 23 12:47:29 GMT 2009, Atul Kulkarni wrote:
> I have a problem of rendering SVG Images in QWebView. The SVG Images are
> replaced with missing image icons ("?"). I am inserting a simple SVG image
> in an XHTML document.
This is a common problem with most Web browsers because SVG support is not
as widespread as it would ideally be. Does the page appear as it should do
in other browsers?
> Can any one help me resolve this problem. I would really appreciate any
> help or direction.
>
> My System and File details as follows:
> OS - Windows XP
> Python 2.5
> PyQt4.4.3 with Qt4
> Using Qt Designer 4.4.1 Open Source Edition
> My PyQt4 plugins has imageformats with qsvg4.dll, qsvgd4.dll
I don't think that Qt's support for SVG will make any difference here
because WebKit is doing the rendering. I don't know what features WebKit
has for embedding SVG 1.1 drawings into pages, but it seems to be able to
display them (Qt 4.4.3, PyQt 4.4.4, Linux) if you pass the URL to the
SVG itself to QWebView's load() method.
In fact, it seems that they can also be embedded into the page. The following
simplified XHTML markup worked for me:
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" lang="en">
<head>
<meta http-equiv="content-type"
content="application/xml+xhtml; charset=UTF-8" />
<title>SVG Test</title>
</head>
<body>
<p>I am Object showing SVG</p>
<object data="test_svg.svg" type="image/svg+xml" height="170" width="325">
Your Browser does not support SVG
</object>
</body>
</html>
Initially, I was convinced it wasn't working because I couldn't see the
picture immediately below the "?" images, but scrolling down to the bottom
of the page revealed it.
David
More information about the PyQt
mailing list