I need to run a for loop to select features by their attributes, because the values are within lists (strkey and strvalue). I'm using the following script:
k=0 v=0 layer = iface.activeLayer() for item in keys: listk = strkey[k] listv = strvalue[v] layer.selectByExpression('\"LINE_ID\" IN ('+listk+') AND \"Declividad\" IN ('+listv+')', QgsVectorLayer.SetSelection) v=v+1 k=k+1
The problem is that only the last feature is selected. Is like every loop the Qgis erases the old selection to select the new feature. Is there a way to accumulate the selections ?