[PyQt] Re: About setting a pixmap as background

David Boddie david at boddie.org.uk
Fri Aug 3 14:42:00 BST 2007


On Fri Aug 3 14:26:38 BST 2007, Gustavo A. Díaz wrote:

> By the way David, anywhere i use SVG images i must render it first?
> And i think yes, cause when i use directly a SVG image that contain shadows
> or transparency, does not look good.

In places where you can only use pixmaps, you will need to render the SVG to
an image first. There are places where you can load an SVG and not worry
about that - when you use QIcon for icons, for example.

> Which are the steps to render? i must load the SVG image with QSvgRenderer
> and then reder with it too?

One nice way of doing this is to use QIcon, though QSvgRenderer might be
better in certain situations. Creating a pixmap from an icon that contains
an SVG drawing is quite simple:

  icon = QIcon(path_to_svg_file)
  pixmap = icon.pixmap(width, height)

The good thing about this is that you only need to load the SVG drawing once.

Of course, if you just want to display an SVG drawing, you can use QSvgWidget
instead.

David



More information about the PyQt mailing list