[PyQt] Re: rendering svg

Niels Egberts niels.egberts at gmail.com
Thu Apr 17 15:20:29 BST 2008


Now I have found this:

self.picture = QtGui.QPicture()
self.picture.load("/home/user/grid.jpg")

And it gives the error:

QPicturePaintEngine::checkFormat: Incorrect header

I have tried with a jpg, bmp, svg and an png but all of them return an
"incorrect header". What am I doing wrong?

Niels

On Wed, Apr 16, 2008 at 9:43 PM, Niels Egberts <niels.egberts at gmail.com>
wrote:

> Hi, I am pretty new to qt4 and python (have have very limited experience
> with C++ and qt3).
>
> I have a QWidget that I am using as a gameboard. So I want to draw svg
> images on it (like chesspieces and such). I have got this now:
>
>
>     def __init__(self, parent=None):
> >         QtGui.QWidget.__init__(self, parent)
> >
> >         self.setGeometry(300, 300, 250, 150)
> >         self.setWindowTitle('Draw Text')
> >
> >         self.picture = QtGui.QPicture()
> >         self.picture.load("images/grid.svg")
> >
> >
> >     def paintEvent(self, event):
> >         paint = QtGui.QPainter()
> >         paint.begin(self)
> >         paint.drawImage(0,0,self.picture)
> >         paint.end()
> >
>
> I understand that I need to place my image in a buffer and then do
> drawImage(0,0,self.buffer) but I can't find out how to do that. Can someone
> give me a code snippit on how I can achieve to render his svg?
>
> Thank you very much,
> Niels
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080417/8a79a6a0/attachment.html


More information about the PyQt mailing list