I'm looking for a way to trigger an event upon clicking on a QgsVertexMarker object which is located on a mapCanvas. In the official docs, there is a mousePressEvent
method which I actually re-implement in my custom QgsVertexMarker class:
class CustomMarker(QgsVertexMarker):
...
def mousePressEvent(self, event):
print("---MOUSE EVENT---")
if event.button() == Qt.LeftButton:
print("Left click")
self.getMarkerProperties()
...
Now, the problem is that I cannot figure out how to make it work. I read about instantiating a QGraphicsView object and eventFilters but I'm not sure if this is the right path to follow.
NOTE: The default implementation of setToolTip
method already works without any tinkering so I'm wondering why mousePressEvent
doesn't work out of the box.