http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qgraphicsitem.html#setRotation

seems that setRotation() sets an absolute value.
not an increment.
if you want to add 90°, you should do something like
self.setRotation(self.rotation()+90)


2010/8/1 Konrad Koller <[email protected]>

> In a game the user should be able to rotate a GraphicsItem by clicking on
> it with the right mouse button. According the game situation he must be able
> to execute another rotation by the same angle (90°). But this time the item
> is not rotated! To explain the situation I add the essential part of my
> code:
>
> class Stone(QGraphicsPolygonItem):
>     def __init__(self,polygon,brush,x,y,scene):
>         QGraphicsPolygonItem.__init__(self,polygon,None,scene)
>         self.setPos(x,y)
>         self.setBrush(brush)
>     def mousePressEvent(self,ev):
>         if ev.button()==Qt.RightButton:
>             print self.sceneBoundingRect()
>             self.setRotation(90)
>             print self.sceneBoundingRect()
>
> Two consecutive clicks produce the following output:
>
> PyQt4.QtCore.QRectF(5.0, 41.0, 90.0, 18.0)
> PyQt4.QtCore.QRectF(41.0, 5.0, 18.0, 90.0)
> PyQt4.QtCore.QRectF(41.0, 5.0, 18.0, 90.0)
> PyQt4.QtCore.QRectF(41.0, 5.0, 18.0, 90.0)
>
> This demonstrates that the second click fails and this can also be watched
> on the screen.
> What am I doing wrong? I ask for a solution because consecutive rotations
> are essential for the game.
>
> Cheers Konrad
>
> PS: For demonstration in this example the polygon is a rectangle, in other
> cases the polygons haves more edges,
>
> _______________________________________________
> PyQt mailing list    [email protected]
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to