How to draw a line with animation in PyQt4

前端 未结 2 824
执笔经年
执笔经年 2021-02-04 13:04

I have a list of points. For example, points = [[160, 75], [115, 567]].

How to draw a line in PyQt4, so it would be something like this:

2条回答
  •  执念已碎
    2021-02-04 14:02

    Refer the below code in your paint event to draw a line in Qt.

    def paintEvent(self, event):
        painter = Qt.QPainter()
        painter.begin(self)
        painter.pen().setWidth(int width)
    painter.setPen(Qt.QColor(100,100,100))
        painter.drawLine(x1,y1,x2,y2)
        painter.end()
        Qt.QFrame.paintEvent(self, event)
    

提交回复
热议问题