[Solved] Python QPixmap positioning?
I'm trying to change the position of a pixmap, but it doesn't seem to be working:
@iconview = QtGui.QGraphicsView()
scn = QtGui.QGraphicsScene(iconView)
pix = QtGui.QPixmap("picture.xpm")
item = QtGui.QGraphicsPixmapItem(scn.addPixmap(pix))
item.setPos(0, 30) # for ex@
It displays the picture, but doesn't move the position...just stays in the center.
Your problem is with the following line:
If you print out the result of sceneRect() you get:
@QRectF(0.0, 0.0, 0.0, 0.0)@
i.e. a rectangle of no size. This is because the QGraphicsView doesn't have a scene from which to get a size yet so returns default. If you set a size as follows your icon will be placed as desired:
@scn.setSceneRect(QRectF(0.0, 0.0, 250.0, 250.0))@
Thanks again, jazzycamel!!! :)