Hi,
I want to ask how can I make a graphic item drag and drop through on a certain line?
Thanks in advance
Hi,
I want to ask how can I make a graphic item drag and drop through on a certain line?
Thanks in advance
Hi,
I wanted to mean along a certain line. In other words, whereever I drag my item in the view, I want it to move along a certain line according to the dragging movements.
In that case you probably want not "dragging" but "moving". You can either reimplement mouseMoveEvent() or itemChange() for the item. Both will allow you to control the position of the item when it is moved with the mouse.
Hi ,
I see but for example what if I want to move the item in x axis with a restricted range let's say between x = 10 and x = -20 ?
I know that and I already read the docs. I try to look at docs before I send threads here.
Anyway, this is ok for rectangular shapes but what I want to really achieve is shapes like polygons or circle.
I think I need something like "closest point" to the shape when I make my item move on the shape in order to keep the item's position on the regarding shape.
Thanks in advance
You can use any math calculations you want. The shape doesn't matter. Remember you always have the boundingRect() you can work with.
Hi again,
But if we can only play with the bounding rectangle, how can we perform this movement on a polygon since the bounding rectangle always returns a QRectF?
I will be pleased if you can give me more tips about it.
Thanks in advance
Sorry for the late answer first,
Yes I can. First of all, think I have a polygonal path for the mouse to be moved on the view. Then please see the following shape I've sent.
In this shape 1,2 and 3 are the example valid mouse locations. Suppose that the white background is the view(or scene) and the polygonal path is the path that the mouse can only move on.
Last edited by zgulser; 6th July 2009 at 13:48.
Bookmarks