[PyQt] Re: About setting a pixmap as background

David Boddie david at boddie.org.uk
Fri Aug 3 13:08:42 BST 2007


On Friday 03 August 2007 03:56, Gustavo A. Dí­az wrote:

> I am afraid that didnt worked, i wrote:
> 
>          self.centralwidget = QtGui.QWidget()
>          palette = self.centralwidget.palette()
>          bgPixmap = QtGui.QPixmap(":/Pixmaps/pixmaps/oc_clientBg.svg")
>          brush = QtGui.QBrush()
>          brush.setTexture(bgPixmap)
>          palette.setBrush(QPalette.Background, brush)
>          self.centralwidget.setPalette(palette)
> 
> The app runs but no pixmap appears as BG and now debug error.

You need to convert the SVG drawing to a pixmap first. One way of doing this
is to use QSvgRenderer; another is to load the SVG file into an QIcon and
generate a pixmap of the desired size using its pixmap() method.

David



More information about the PyQt mailing list