anda_skoa told you it wouldn't do the trick because you are mixing two coordinate spaces.

Quote Originally Posted by ayanda83
I want to limit the movement of the child item to the bounds of the parent item
Bounds of the parent item:
Qt Code:
  1. QRectF bounds = parent->boundingRect();
To copy to clipboard, switch view to plain text mode 
Limit movement of child to that rect:
Qt Code:
  1. if(!bounds.contains(pos())) { ... }
To copy to clipboard, switch view to plain text mode 

Riddle:
What coordinate space are we using here?
a) item
b) item's parent
c) scene