Repaint() function paints only last point!!
-
-
Hi and welcome to devnet,
As Johan said, calling repaint like that is a bad idea. If you want to animate the painting you should rather use e.g. a QTimer.
Also, you have to pay attention on the value of x, just incrementing it will make it larger than your widget.
-
The actual func() is line drawing algorithms,dda()
And bresenham(). I had written these functions in paintevent itself but the teacher told me to make separate functions.
Hence i had to call repaint().
The algorithm increments or decrements the global variables x and y according to the algorithm and i expect repaint to draw the points.
Hope i made my point clear.
Thank you -
Hi, repaint() is usually called when you want to clean or refresh your widget's screen area, what I mean: you call "erase screen" 100 times and drawPoint() 100 times :-)
Best is to do what SGaist suggests,use a QTimer.
Or you can change your code in Widget::paintEvent() so that first time it's called it draws just one point; then next time it's called, redraw previous point and one more, next time draw 3 points etc.
-
Breaking a big function in smaller pieces doesn't mean you need to redo your logic. If your teacher was happy with your first implementation, just keep it and isolate each part