In QGIS 3.22 I'm facing a problem with QgsMapLayer
. I want to use it on QGIS in order to modify the symbology of line, point & polygon in each layer but every time it gives me an error on using the library of PyQGIS.
This is the script I'm using:
from PyQt5.QtGui import *
from qgis.core import *
lyr = QgsVectorLayer("PATH", 'ligne', 'ogr')
QgsProject.instance().addMapLayer(lyr)
sym = QgsLineSymbol.createSimple({'Line_style': 'dash','Color': 'red'})
symbol= lyr.QgsMapLayer.createMapRenderer().symbols(QgsRenderContext())
sym = symbols[0]
lyr.triggerRepaint()
from PyQt5.QtGui import *
from qgis.core import *
lyr = QgsVectorLayer("PATH", 'ligne', 'ogr')
QgsProject.instance().addMapLayer(lyr)
sym = QgsLineSymbol.createSimple({'Line_style': 'dash', 'Color': 'red'})
symbol = lyr.QgsMapLayer.createMapRenderer().symbols(QgsRenderContext())
sym = symbols[0]
lyr.triggerRepaint()
And here is the error message:
AttributeError: 'QgsVectorLayer' object has no attribute 'QgsMapLayer'
I have QGIS 3.22
AttributeError: 'QgsVectorLayer' object has no attribute 'QgsMapLayer'
Is there is any solution for that?