When a user clicks, the mouse position x & y value is stored in a QList<int>
User will be able to click several times

My problem is if a user clicks the same spot where he/she already clicked
that x & y value must be deleted from the array only.

This is so far what i got:
Qt Code:
  1. //In mouseMove function
  2. if(ev->button()==Qt::LeftButton)
  3. {
  4. x1 = ev->x();
  5. y1 = ev->y(); //x1,y1 are temp variables later in same function used to .append into array
  6. ...
  7. }
To copy to clipboard, switch view to plain text mode 
RemoveValue function is:
Qt Code:
  1. void class::RemovePoint()
  2. {
  3. int r = 0;
  4. do
  5. {
  6. //Only 1 Array stored in format x|y|x|y|x|y|x|y|x|y|...
  7. if(Array1[r] == x1 && Array1[r+1] == y1)
  8. {
  9. Array1.removeAt(r);
  10. Array1.removeAt(r);
  11. }
  12. r = r + 2; //Jumps to next x value
  13. }while(r < 50); lets say 25 points, hence x & y values = 50 array elements
  14. }
To copy to clipboard, switch view to plain text mode 

I am not worried about the display
Just need the array to be updated as it happens

Program compiles
when I test the same point
Program crashes
[Invalid parameter passing & Assert Failure :"index out of range"

Help Appreciated...Much
Thanks