Skip to main content
added 5 characters in body
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

I don't fully understand what you are trying to do but try this:

lyr = QgsVectorLayer("PATH", 'ligne', 'ogr')
QgsProject.instance().addMapLayer(lyr)

sym = QgsLineSymbol.createSimple({'line_style':'dash','color':'red'})
lyr.renderer().setSymbol(sym)
lyr.triggerRepaint()
lyr = QgsVectorLayer("PATH", 'ligne', 'ogr')
QgsProject.instance().addMapLayer(lyr)

sym = QgsLineSymbol.createSimple({'line_style':'dash', 'color':'red'})
lyr.renderer().setSymbol(sym)
lyr.triggerRepaint()

line_style and color are case-sensitive. Don't use Line_style and Color.

enter image description here

I don't fully understand what you are trying to do but try this:

lyr = QgsVectorLayer("PATH", 'ligne', 'ogr')
QgsProject.instance().addMapLayer(lyr)

sym = QgsLineSymbol.createSimple({'line_style':'dash','color':'red'})
lyr.renderer().setSymbol(sym)
lyr.triggerRepaint()

line_style and color are case-sensitive. Don't use Line_style and Color.

enter image description here

I don't fully understand what you are trying to do but try this:

lyr = QgsVectorLayer("PATH", 'ligne', 'ogr')
QgsProject.instance().addMapLayer(lyr)

sym = QgsLineSymbol.createSimple({'line_style':'dash', 'color':'red'})
lyr.renderer().setSymbol(sym)
lyr.triggerRepaint()

line_style and color are case-sensitive. Don't use Line_style and Color.

enter image description here

Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

I don't fully understand what you are trying to do but try this:

lyr = QgsVectorLayer("PATH", 'ligne', 'ogr')
QgsProject.instance().addMapLayer(lyr)

sym = QgsLineSymbol.createSimple({'line_style':'dash','color':'red'})
lyr.renderer().setSymbol(sym)
lyr.triggerRepaint()

line_style and color are case-sensitive. Don't use Line_style and Color.

enter image description here