ビューで線を書く

2016/12/13

Python2.7.10, PyQt4.11.3

class MyScene(QtGui.QGraphicsScene):

    def __init__(self,parent):
        super(MyScene, self).__init__(parent)

    def  drawLine(self,x1,y1,x2,y2):
        pen = QtGui.QPen()
        qc = QtGui.QColor()
        qc.setNamedColor('#000000')
        pen.setColor(qc)

        self.addLine(QtCore.QLine(x1,y1,x2,y2),pen)