I&#39;ve been playing with the diagramscene demo, which is a great way to learn about QDiagramScene, and found some odd behaviour which a search of the archives doesn&#39;t illuminate. It&#39;s easy to recreate with minor changes to the original demo code.<br>
<br>The following line (355) in the MainWindow constructor sets the size of the scene:<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">scene.setSceneRect(QtCore.QRectF(0, 0, 5000, 5000))</span><br>
<br>Commenting it out sets the scene to it&#39;s default behaviour which is to automatically expand to encompass any items added to it. The scene size will be set to the view size when the view is created so you won&#39;t see any scroll bars when the app launches.<br>
<br>Add an item to the scene and then slowly move the item to the left pixel by pixel until it just barely touches or moves beyond the edge of the view area. If you do it slowly enough the item disappears. What has happened is that the scene has been automatically &#39;grown&#39; to the left and the item has been moved to the left hand edge of the scene, beyond the current view area. Use the new scroll bar to look left and you&#39;ll find it.<br>
<br>If you move the item more quickly, you won&#39;t notice this because the item blinks for an instant but then reappears where you expect it. The teleport behaviour only occurs if it is moved very carefully. Moving the item off the other edges also displays odd behaviour. e.g. slowly moving it off the right or bottom edges causes it to &#39;bounce&#39; back a few hundred pixels.<br>
<br>This can be seen more easily by instrumenting the DiagramItem class&#39;s itemChanged method with a print command at line 211 to track the item co-ordinates as follows:<br><br><span style="font-family: courier new,monospace;">    def itemChange(self, change, value):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        if change == QtGui.QGraphicsItem.ItemPositionChange:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            for arrow in self.arrows:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                arrow.updatePosition()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            print self.mapToScene(self.x(),self.y())</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        return QtCore.QVariant(value)</span><br><br>You need to rename the app to diagramscene.py so that the console window displays. You don&#39;t need to move the item as carefully, but can see the anomalous co-ordinates show up in the command window.<br>
<br>It&#39;s not clear to me if this is a bug in PyQT, or in the example app, or more likely I&#39;m just bending the example app in ways it&#39;s not designed to be bent. Any suggestions?<br><br>Best regards,<br><br>Simon Hibbs<br>
<br>