I am trying to migrate a plugin from QGIS 2 to QGIS 3. This function doesn't work with QGIS 3 :
def getLayersByKeyWord(keyword):
#retourne une liste de layer
res=[]
layerMap = QgsMapLayerRegistry.instance().mapLayers()
for name, layer in layerMap.iteritems():
if layer.keywordList() == keyword:
res.append(layer)
if len(res)>0:
return res
else:
return None
I tried to replace QgsMapLayerRegistry
with QgsProject
but it is still not working on iteritems()
.
I still have this error : for name, layer in layerMap.items: TypeError: 'builtin_function_or_method' object is not iterable