[PyQt] QGraphicsView to display a png

Adam Tenderholt atenderholt at gmail.com
Mon Jul 23 23:06:34 BST 2007


I think you are drawing your pixmap off the edge of the scene. Try the
following:

scene = QtGui.QGraphicsScene()

#scene.setSceneRect(-600,-600, 600,600)
scene.setSceneRect(-600, -600, 1200, 1200)

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

Adam

On 7/21/07, kib2 <kib2 at free.fr> wrote:
> 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.
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>


More information about the PyQt mailing list