I want to iterate over line features to change color of each feature to the color I choose. So my file has 7 features, I want am writing the code below, but it does not seem to work.
line_feats = [f for f in line_layer.getFeatures()]
clr = ["blue","red","green","yellow","magenta","cyan","black","red"]
for l in line_feats:
line_layer.select(l.id())
iface.mapCanvas().setSelectionColor( QColor(clr[l.id()]))
line_layer.triggerRepaint()
I have tried printing l.id() and it goes from0from 0 to 7, so indexing is not the issue. The thing is, it does not change the color individually, rather it changes for the entire file.