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:<br>
<br>class Stone(QGraphicsPolygonItem):<br> def __init__(self,polygon,brush,x,y,scene):<br> QGraphicsPolygonItem.__init__(self,polygon,None,scene)<br> self.setPos(x,y)<br> self.setBrush(brush)<br> def mousePressEvent(self,ev):<br>
if ev.button()==Qt.RightButton:<br> print self.sceneBoundingRect()<br> self.setRotation(90)<br> print self.sceneBoundingRect()<br><br>Two consecutive clicks produce the following output:<br>
<br>PyQt4.QtCore.QRectF(5.0, 41.0, 90.0, 18.0)<br>PyQt4.QtCore.QRectF(41.0, 5.0, 18.0, 90.0)<br>PyQt4.QtCore.QRectF(41.0, 5.0, 18.0, 90.0)<br>PyQt4.QtCore.QRectF(41.0, 5.0, 18.0, 90.0)<br><br>This demonstrates that the second click fails and this can also be watched on the screen. <br>
What am I doing wrong? I ask for a solution because consecutive rotations are essential for the game.<br><br>Cheers Konrad<br><br>PS: For demonstration in this example the polygon is a rectangle, in other cases the polygons haves more edges,<br>