ビューでポリゴンを描く
2016/12/13
Python2.7.10, PyQt4.11.3
class MyScene(QtGui.QGraphicsScene):
def __init__(self,parent):
super(MyScene, self).__init__(parent)
def drawPolygon(self,x,y):
pen = QtGui.QPen()
qc = QtGui.QColor()
qc.setNamedColor('#000000')
pen.setColor(qc)
brush = QtGui.QBrush()
brush.setStyle(QtCore.Qt.SolidPattern)
qc = QtGui.QColor()
qc.setNamedColor('#bac6ed')
brush.setColor(qc)
points = [QtCore.QPointF(x[0],y[0]),
QtCore.QPointF(x[1],y[1]),
QtCore.QPointF(x[2],y[2]),
QtCore.QPointF(x[3],y[3])]
self.addPolygon(points,pen,brush)