0

I have built a QGIS Plugin which activates the QgsMapToolEmitPoint for getting XY-Coords when I click on the map. Everything works as desired with the following code:

def foo(tool):
    click = (tool.x(), tool.y())
    do something ....

canvas = iface.mapCanvas()
tool = QgsMapToolEmitPoint(canvas)
tool.setCursor(Qt.SizeAllCursor)
tool.canvasClicked.connect(foo)
canvas.setMapTool(tool)

But there is a little problem left: When i have an activated Rasterlayer, styled as greyscale, sometimes it's hard to see where the Cross of the MapTool is. I just found how to change the Cursor from Cross to different Cursor Shapes from https://doc.qt.io/archives/qt-4.8/qt.html#CursorShape-enum

So I have the following question: Is there a possibility to change the color of the MapTool e.g. to red?

1 Answer 1

2

I don't know it's possible to change cursor color, but you can make your own cursor from an image file.

cursor = QCursor(QPixmap("C:/cursor.png"))
tool.setCursor(cursor)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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