1

I have a vector layer with a "Simple Marker" for the style. I see I can create Data Defined properties for both the colour and the outline colours.

In Python, I'm able to change the marker's base colour (for the data defined property), but I can't seem to find how to change the outline's colour.

Here's what I have:

symbols = layer.rendererV2().symbols()
symbol = symbols[0]

expr = 'color_rgba(255,0,0,0)'
symbol.symbolLayer(0).setDataDefinedProperty('color', expr)

# I would expect this to work, but it doesn't
symbol.symbolLayer(0).setDataDefinedProperty('outlineColor', expr)

Any ideas?

  • From Symbology of vector layers in QGIS Python Plugins : "The names of available properties can be found using the properties method of an existing symbol layer: symbol_layer.properties()". Hopefully it will help you to find the right property name. – ArMoraer Sep 10 '16 at 5:24
  • In this case, 'color_border' is the adequate property for color border. – xunilk Sep 10 '16 at 8:09
3

Next code works [but I used 'color_rgba(255,0,0,255)' to avoid complete transparency]; where 'color_border' is the adequate property for color border.

layer = iface.activeLayer()

symbols = layer.rendererV2().symbols()

symbol = symbols[0]

expr = 'color_rgba(255,0,0,255)'
symbol.symbolLayer(0).setDataDefinedProperty('color', expr)

# I would expect this to work, but it doesn't
symbol.symbolLayer(0).setDataDefinedProperty('color_border', expr)

layer.triggerRepaint()

iface.legendInterface().refreshLayerSymbology(layer)
  • 'color_border' - exactly what I needed, thanks! It was so hard to find and not at all intuitive. – DFx Sep 10 '16 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.