View Full Version : Cancelling last point displayed QPainter

19th June 2013, 16:38
point is shown where user clicks(left/right click) ->stored in array, point displayed via the same array

Created a pop up menu on right click
which includes a Cancel option
which needs to clear the last action the painter function done
(for instance the last action was drawing a point at x,y -> that point needs to be cleared, but only that point)

How do I go about doing that

19th June 2013, 23:11
You can't. You have to repaint all points or use e.g. a QGraphicsScene/View.

20th June 2013, 08:27
How do I call repaint again.
I created an if statement in my paint function within label-class

if (cancel ==true)
//cancel last point
//delete point from array

How do I recall paint in the if statement with the updated array
so only the points now in array will be displayed?

Or do I create another paint function & call it from the original paint function.

//Getting to grips with the paint function!

Kind Regards

21st June 2013, 15:59
Well you have a array, where you store the points. Then simply add/remove points of that array (e.g. QList<QPoint>) and afterwards call update(). Inside the paint method I wouldn't do any logic. simply paint all points of the array.