[PyQt] QGraphicsView to display a png

kib2 kib2 at free.fr
Sat Jul 21 20:49:54 BST 2007


Hi,

This is the first time I'm playing with QGraphicsView.
My aim was simply to display a png image inside it (I need something 
more convenient than a QLabel).

Here's some part of my code (self.gv is just a QGraphicsView instance 
and a directory "images" has been created inside my script dir 
containing the image "triangle.png"):

----->----->----->----->
scene = QtGui.QGraphicsScene()
scene.setSceneRect(-600,-600, 600,600)
pic = QtGui.QPixmap(":/images/triangle.png")
scene.addItem(QtGui.QGraphicsPixmapItem(pic))
view = self.gv
view.setScene(scene)
view.setRenderHint(QtGui.QPainter.Antialiasing)
view.show()
----->----->----->----->

Result : only a black area.
Did I miss something ?
Thanks.


More information about the PyQt mailing list