So I've managed to get a graph drawn up on my screen like such:
class Window(QWidget):
#stuff
graphicsView = QGraphicsView(self)
scene = QGraphicsScene(self)
#draw our nodes and edges.
for i in range(0, len(MAIN_WORLD.currentMax.tour) - 1):
node = QGraphicsRectItem(MAIN_WORLD.currentMax.tour[i][0]/3, MAIN_WORLD.currentMax.tour[i][1]/3, 5, 5)
edge = QGraphicsLineItem(MAIN_WORLD.currentMax.tour[i][0]/3, MAIN_WORLD.currentMax.tour[i][1]/3,
MAIN_WORLD.currentMax.tour[i+1][0]/3, MAIN_WORLD.currentMax.tour[i+1][1]/3)
scene.addItem(node)
scene.addItem(edge)
#now go back and draw our connecting edge. Connects end to home node.
connectingEdge = QGraphicsLineItem(MAIN_WORLD.currentMax.tour[0][0]/3, MAIN_WORLD.currentMax.tour[0][1]/3,
MAIN_WORLD.currentMax.tour[len(MAIN_WORLD.currentMax.tour) - 1][0]/3, MAIN_WORLD.currentMax.tour[len(MAIN_WORLD.currentMax.tour) - 1][1]/3)
scene.addItem(connectingEdge)
graphicsView.setScene(scene)
hbox = QVBoxLayout(self)
#some more stuff..
hbox.addWidget(graphicsView)
self.setLayout(hbox)
Now, the edges are going to be updating constantly, so I want to be able to remove those edges and redraw them. How can I do that?