QGraphicsView Framework coordinate mapping problem
Hi,
I have an item which resides in an item group. Note that I did;
Code:
setHandlesChildEvents(TRUE)
.
When I move my item by the cursor(drag-drop), I want to see, update and maintain it's position. But here are the problems...
1. When I print out the item's position in item group like ;
Code:
cout<<"Position of item , x-coordinate: "<<item->pos().x()<<endl;
cout<<"Position of item , y-coordinate: "<<item->pos().y()<<endl
it gives me a pair of (0,0). Isn't that odd?
2. When I print out the item group's coordinates like;
Code:
cout<<"Position of item , x-coordinate: "<<pos().x()<<endl;
cout<<"Position of item , y-coordinate: "<<pos().y()<<endl
it gives me the values in local coordinates. How can I convert these to scene coordinates? mapToScene(pos()) gives the same result by the way!
Re: QGraphicsView Framework coordinate mapping problem
Hard to answer without knowing where you display the coordinates values.
For instance, in item change, you can get coordinates before modification.
Since coordinates of an item are relative to its parent, it may be normal to have (0,0) if it is a child item, as part of the group.
You might try to combine mapFromScene and mapFromParent to control extacly the reference coordinates system : scene, group, item?
S.Cascio