I want to copy-paste values from one feature in a layer to another feature in another layer, for this, I like to have both layers activated to be able to select features from both layers.
Just as an example: I have a QGIS project with two layers running ('source' and 'target') and this script:
from qgis.core import *
def onFeatureIdentified(feature):
fid = feature.id()
print ("feature selected : " + str(fid))
layer = iface.activeLayer()
#print(layer.name())
mc=iface.mapCanvas()
mapTool = QgsMapToolIdentifyFeature(mc)
print(mapTool)
mapTool.setLayer(layer)
mc.setMapTool(mapTool)
mapTool.featureIdentified.connect(onFeatureIdentified)
This script does only work when I first activate a layer in the TOC in QGIS, then all applies only to that layer. However, I would like to be able to 'switch' to the other layer, so that when I click on the other (till then inactive) layer, it automatically activates the other layer.
Is there a way to do this?
There is already the Mulitlayer Select tool, which does what I want(so you can select features from more layers), but when I enable it, then the script doesn't work anymore (I think it levers out the QgsMapToolIdentifyFeature
function).
So I need another way to activate both layers.