QGraphicsItem::pos returns the position of item in "parent coordinates".
The value (0, 0) is the result of "pos()" or "toPoint()"?
QGraphicsItem::pos returns the position of item in "parent coordinates".
The value (0, 0) is the result of "pos()" or "toPoint()"?
A camel can go 14 days without drink,
I can't!!!
Both. Even in parent coordinates they should not be 0,0
And as I understand toPoint just "rounds" coordinates and returns integer values...
rightAnd as I understand toPoint just "rounds" coordinates and returns integer values...
Can you post the code where you set the item's position?
Last edited by mcosta; 19th July 2011 at 20:39. Reason: updated contents
A camel can go 14 days without drink,
I can't!!!
It is posted)
I invoke this function in the graphicsview class while reading all layers. Like this:
Qt Code:
for(int i=0;i<userLayers->childItems().count();i++) { QGSLayer *lyr = (QGSLayer *)userLayers->childItems().at(i); lyr->updateFeatures(oldZoom); }To copy to clipboard, switch view to plain text mode
This is a piece of your code.
Qt Code:
item->setPos(pt);To copy to clipboard, switch view to plain text mode
You
- convert the position from scene coordinate to meters (using zoom probably)
- convert meters to LatLong (using a Reference Point)
- convert LatLong in meters
- convert meters in scene coordinates.
It's normal that, if the initial position is (0,0), the new one will be (0,0).
Are you sure the algorithm you used is correct?
A camel can go 14 days without drink,
I can't!!!
Em... The initial position is hardly 0,0... Look at the picture attached. Black dots are points.
Hi Kefir,
you should use scenePos() to get the position of your items AFIK the pos() method will return 0,0 i.e origin of the item itself in local coordinates. Though Qt documentation says that a parent less item will return position coordinates in terms of Scene. From the code and snap shot it seems that you are developing a GIS application. I would appreciate if you could share some information on your application I am also into GIS application development.
With regards
Sukesh
Thank you, Sukesh!
But I have doubts that pos() returns origin of the item, as it... But I'll try thinking in this direction...Returns the position of the item in parent coordinates. If the item has no parent, its position is given in scene coordinates.
Actually it is GIS API. So far I succesfully load google/openstreet/yandex and GeoServer tiles, zoom in/out, add features by coordinate. I'm afraid I can't give you my sources as this development is for my company and it is not opensource. However I answer some questions and give you links that may help you)
Bookmarks