from PyQt4 import QtGui, QtCore

app = QtGui.QApplication([])

v = QtGui.QGraphicsView()
s = QtGui.QGraphicsScene()
v.setScene(s)
v.show()

v.resize(640, 480)
# Using smaller window fixes the problem in this example
#v.resize(600, 400)

# this path disappears when its starting point crosses the view edge
path = QtGui.QPainterPath()
path.moveTo(0,0)
path.lineTo(0.5, 1e-7)
path.lineTo(1, 1)

# this path also disappears
path2 = QtGui.QPainterPath()
path2.moveTo(0.5, 1e-7)
path2.lineTo(1, 1)

# this path does not disappear
path3 = QtGui.QPainterPath()
path3.moveTo(0,0)
path3.lineTo(0.5, 1e-7)

pi1 = QtGui.QGraphicsPathItem(path)
pi1.setPen(QtGui.QPen(QtGui.QColor(255, 0, 0)))

pi2 = QtGui.QGraphicsPathItem(path2)
pi2.translate(0.1, 0)
pi2.setPen(QtGui.QPen(QtGui.QColor(0, 255, 0)))

pi3 = QtGui.QGraphicsPathItem(path3)
pi3.translate(0.1, 0)
pi3.setPen(QtGui.QPen(QtGui.QColor(0, 0, 255)))

s.addItem(pi1)
s.addItem(pi2)
s.addItem(pi3)

y = -0.5e-7
def update():
    global y
    rect = QtCore.QRectF(-.1, y, 1, 2e-7)
    v.setSceneRect(rect)
    v.fitInView(rect, QtCore.Qt.IgnoreAspectRatio)
    y += 0.01e-7
    if y > 1.2e-7:
        y = -0.5e-7
    
timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(20)

QtGui.QApplication.instance().exec_()

