[PyQt] QGraphicsView to display a png

kib2 kib2 at free.fr
Mon Jul 23 23:55:57 BST 2007


David Boddie a écrit :

> 
> That might fix the problem. Another question worth asking is: have the
> resources been set up correctly? The assignment,
> 
>   pic = QtGui.QPixmap(":/images/triangle.png")
> 
> refers to an image in a resource that is usually stored in a module
> and imported somewhere in an application before it is used. The image
> may reside in images/triangle.png but the original poster needs to
> create a .qrc file that lists it, run pyrcc4 on the .qrc file to
> generate a Python module, and import that to make it work.
> 
> Some of the examples included with PyQt4 use .qrc files to package
> images and other resources as Python modules, so there should be
> plenty of examples worth looking at.
> 
> David
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> 

Thanks for your hints,

in fact the problem has been solved yesterday...
My scene was refering to nothing at all, add a "self" like this :

scene = QtGui.QGraphicsScene(self)

and the image appears.

Now, Dave just told me it was a bad idea to put an image on a 
QGraphicsView. I've already done it inside a Label, but I've no controls 
on it. He suggested I've to write my own widget (from Qlabel or QWidget) 
for that, but I don't see why it's a bad design decision.

David : thanks again for your good work on the wiki.


More information about the PyQt mailing list