How to draw a line with animation in PyQt4

前端 未结 2 822
执笔经年
执笔经年 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 13:49

    1. If you are using normal widgets then you would be looking at QPainter.drawPath()
    2. If you are using QGraphics, then you would be looking at QGraphicsPathItem

    Either of these two would have similar approaches where during your draw you would have to build the line incrementally over time. Review your own previous question for a specific example of how to draw a line over time: Make an animated wave with drawPolyline in PySide/PyQt

    As an example, if you were using QGraphics, then you would have a QGraphicsPathItem instance in your scene. Then you would animate it by looping and updating QPainterPath by incrementally setting the complete path: http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qpainterpath.html#cubicTo

提交回复
热议问题