I am updating a QGIS2 plugin to QGIS3. The following code in PyQGIS2 works:
association_symbol = QgsSymbolLayerV2Registry.instance().symbolLayerMetadata("ArrowLine").createSymbolLayer({
'arrow_width': '0.4',
'head_length': '2.0',
'head_thickness' : '0.75',
'color': 'red',
'line_color': 'red',
'is_curved': '0',
'arrow_start_width': '.2'
})
self.road_object_path_association_layer.rendererV2().symbols()[0].appendSymbolLayer(association_symbol)
I made an attempt at correcting for PyQGIS3, but it does not work:
association_symbol = QgsApplication.symbolLayerRegistry().symbolLayerMetadata("ArrowLine").createSymbolLayer({
'arrow_width': '0.4',
'head_length': '2.0',
'head_thickness' : '0.75',
'color': 'red',
'line_color': 'red',
'is_curved': '0',
'arrow_start_width': '.2'
})
self.road_object_path_association_layer.renderer().symbol().symbolLayers()[0].appendSymbolLayer(association_symbol)
The error returned is as follows:
AttributeError: 'QgsSimpleLineSymbolLayer' object has no attribute 'appendSymbolLayer'
The symbols()
object required an argument. I was not sure what argument to provide. Further research let me to believe I could get the info from the symbolLayers()[0]
object, but that appears to have been a red herring. Any assistance would be helpful.