I would like to move the cursor to a given x,y coordinates of the MapCanvas.
Is there an easy way to do this using PyQGIS?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
You can move cursor like that:
from PyQt4.QtGui import * from PyQt4.QtCore import * cursor = QCursor() cursor.setPos(100, 200)
It moves your cursor to point 100,200 in your screen. If you want to get coordinate of a point on the map canvas, you need to translate them:
# coordinates of point on map canvas point = QPoint(100,100) # translate widget coordinates to global screen coordinates global_point = iface.mapCanvas().mapToGlobal(QPoint(100,100)) # set cursor to these coords cursor.setPos(global_point.x(), global_point.y())