Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to add a symbolLayer with a line-decoration (line-arrow) to a vectorlayer of linestrings. what i am trying at the moment is to create a new layer and set it's QgsLineSymbol with a list of symbollayers.

# Symbology
        simple_props = { 'width' : '1', 'color' : '255,255,255' }
        deco_props = { 'width' : '0.26', 'color' : '0,0,255' }

        simple = QgsSymbolLayerV2Registry.instance().symbolLayerMetadata("SimpleLine").createSymbolLayer(simple_props)
        deco = QgsSymbolLayerV2Registry.instance().symbolLayerMetadata("LineDecoration").createSymbolLayer(deco_props)
        s = QgsLineSymbolV2([simple, deco])

        self.ll.setRendererV2( QgsSingleSymbolRendererV2( s ) ) 

Every time QGIS trys to set the QgsLineSymbolV2 it crashes with a win32-exception. what am i doing wrong, or is there a possibilty to just add a new symbollayer to a existing vectorlayer?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

So i don't know what was wrong, but i found a workaround. now i just add a second symbollayer to the existing symbol in the layer-renderer.

    sl = QgsSymbolLayerV2Registry.instance().symbolLayerMetadata("LineDecoration").createSymbolLayer({ 'width' : '0.26', 'color' : '0,0,0' })
    symbollist = layer.rendererV2().symbols()
    symbol = symbollist[0]
    symbol.appendSymbolLayer(sl)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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