I would like to take control of the mouse pointer in QGIS (for example constraining it to a given extent…) Is there any way to do that using PyQGIS?
[GIS] way to take control of the mouse pointer using python in QGIS
mouse positionpyqgispythonqgis
mouse positionpyqgispythonqgis
I would like to take control of the mouse pointer in QGIS (for example constraining it to a given extent…) Is there any way to do that using PyQGIS?
Best Answer
This standalone python snippet uses the
setPos
method ofQCursor
to move my mouse pointer to the top left corner of my screen:(Note this is standalone python, not QGIS python. But the last two lines should work in a QGIS python console.)
You could then constrain it to an extent by trapping mouse events and resetting. You need a good understanding of Qt (the underlying user interface library of QGIS) to do this well. Search for "qt move mouse pointer" and similar for much enlightenment.