I'm having a weird problem: my whole QGraphicsView goes crazy if I uncomment the following lines in a class (of QtGui.QGraphicsItem):<div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if len( self.points ) == 1:</div>
<div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>rect = QtCore.QRectF(<span class="Apple-tab-span" style="white-space:pre"> </span>self.points[0].x()-self.radius, </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>self.points[0].y()-self.radius,</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>self.points[0].x()+self.radius, </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>self.points[0].y()+self.radius )</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>return rect</div></div><div><br></div></div><div>Here is the full boundingRect function:</div><div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>def boundingRect( self ):</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>if len( self.points ) == 1:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>rect = QtCore.QRectF(<span class="Apple-tab-span" style="white-space:pre"> </span>self.points[0].x()-self.radius, </div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>self.points[0].y()-self.radius,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>self.points[0].x()+self.radius, </div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>self.points[0].y()+self.radius )</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return rect</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>poly = QtGui.QGraphicsPolygonItem( self.polygon )</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>poly.setPen( self.pen )</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return poly.boundingRect()</div></div><div><br></div><div>
What happens is that the view moves to top-left corner _sometimes_ when the rectangle code is run.</div><div><br></div><div>Here is my full code (just rename an image to big.jpg next to the file):</div><div><a href="http://pastebin.com/h9tFZmpk">http://pastebin.com/h9tFZmpk</a></div>
<div><br></div><div>I believe it's a bug in PyQt4, can you have a look at it?</div><div><br></div><div>Regards,</div><div>Zsolt</div><div><br></div><div><br></div>