pratham_shah
29th April 2013, 08:17
I have an application (consider something like paint) where in I create custom QGraphicsItem ( assume something similar to a rectangle for understanding the problem). There is a functionality where in the user can resize the QGraphicsItem, but the item must maintain some aspect ratio. (i.e. for eg. the height of the rectangle cannot be greater than half its width).
For resizing I create 4 QGraphicsItem object which are positioned at the four corners. Clicking on the resize rects and dragging the mouse resizes the associated QGraphicsItem.
Now on clicking any resize rects the resizing starts and the size of the QGraphicsItem changes according to the mouse move while maintaining the aspect ratio.
So for the rectangle after the height is equal to half its width the size of the QGraphicsItem doesn't change for any mouse move in vertical direction ( i.e. the height of the QGraphicsItem wont change on dragging the mouse vertically down).
But my problem is that when I move the mouse vertically down after the rectangle has height is equal to half its width the resize rect should still stay at the corner of the QGraphicsItem.
Currently it moves along with the mouse.
Is there any way to achieve it ?
For resizing I create 4 QGraphicsItem object which are positioned at the four corners. Clicking on the resize rects and dragging the mouse resizes the associated QGraphicsItem.
Now on clicking any resize rects the resizing starts and the size of the QGraphicsItem changes according to the mouse move while maintaining the aspect ratio.
So for the rectangle after the height is equal to half its width the size of the QGraphicsItem doesn't change for any mouse move in vertical direction ( i.e. the height of the QGraphicsItem wont change on dragging the mouse vertically down).
But my problem is that when I move the mouse vertically down after the rectangle has height is equal to half its width the resize rect should still stay at the corner of the QGraphicsItem.
Currently it moves along with the mouse.
Is there any way to achieve it ?