Hi I am new to this stuff and so sorry if I ask any stupid questions.

What I am trying to do is rotating a pixmap item so that it can move in a straight line towards another item on the scene, whilst constantly updating the angle at which it has to move to.

The problem I have is that when the item has to gradually make it's way to the correct angle it stops before it has reached the correct angle. It also jumps before doing the rotation. If I just set it to rotate to correct angle it works and also jumps, but this doesn't work for the other item which works for the other way of rotating

This is the rotation part of the advance function that does the rotation.
Qt Code:
  1. if(shipangle!=0)
  2. {
  3. if(target->x()<x())
  4. {
  5. shipangle = shipangle*(-1);
  6. }
  7.  
  8. if(nextangle<shipangle)
  9. {
  10. setTransformOriginPoint(0,0);
  11. nextangle = nextangle + turnspeed;
  12. qreal properangle = nextangle-shipangle;
  13. qDebug()<<"---START---";
  14. qDebug()<<"PROPER ANGLE : "<< properangle;
  15. qDebug()<<"NEXT ANGLE : " <<nextangle;
  16. qDebug()<<"SHIP ANGLE : "<<shipangle;
  17. qDebug()<<"---STOP---";
  18. setRotation(properangle);
  19. }
  20.  
  21. else if(nextangle>shipangle)
  22. {
  23. setTransformOriginPoint(0,0);
  24. nextangle = nextangle - turnspeed;
  25. qreal properangle = nextangle-shipangle;
  26. setRotation(properangle);
  27. }
  28. }
To copy to clipboard, switch view to plain text mode 

This is where the shipangle is set.
Qt Code:
  1. qreal xdistance = (target->x()-x());
  2. qreal ydistance = (target->y()-y());
  3. qreal hypotenuse = qSqrt(qPow(xdistance,2)+qPow(ydistance,2));
  4. shipangle = (qAcos(xdistance/hypotenuse)*(180/M_PI));
  5. return hypotenuse;
To copy to clipboard, switch view to plain text mode 

Here is a screen shot of the layout.
example.png

Thanks in advance for your help.