How can a double-click in the QGIS canvas be used to run a function in PyQGIS?
For example, I want to access the name of each feature I'm selecting with a double-click.
Code sample to access the selected features names (their names are stored in the first field of their attribute table):
from qgis.core import *
def get_feature_name(self):
vlayer = QgsProject.instance().mapLayersByName('layer')[0]
for f in vlayer.selectedFeatures():
feature_name = f.attribute(0) # results in Group 1
print(feature_name)
I'm aware there is the canvasDoubleClickEvent() but I'm struggling to make it work...