8

I have a point, which has map (canvas) coordinates and it would be great to have his screen position. I need this for setting cursor position in the same place, where point is located.

Do you know any way to convert this coordinates?

7

I think something like the following could work in which you need to transform your map coordinates into screen coordinates using QgsMapTool::toCanvasCoordinates. Select a point in your layer then run the following in the Python Console:

from qgis.gui import QgsMapTool
from PyQt4.QtGui import QCursor

layer = iface.activeLayer()
for f in layer.selectedFeatures():
    geom = f.geometry()
    point = QgsMapTool(iface.mapCanvas()).toCanvasCoordinates(geom.asPoint())
    transformed_point = iface.mapCanvas().mapToGlobal(point)
    QCursor().setPos(transformed_point.x(), transformed_point.y())
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.