2

I have a vector layer in QGIS and using Python I would like to be able to export the layer styling to a string variable and import styling in a string variable to the layer again (pseudo code):

style_string = layer_1.rendererV2().export_style()
layer_2.rendererV2().import_style(style_string))

I have found the two methods writeSld(...) and loadSld(...) in the QgsFeatureRendererV2 but I cannot find any examples of how to use them together.

The only clue I have found was this blog post which describes how writeSld(...) can be used. But when I try to import the XML document back into the renderer using loadSld(...) QGIS gives me a minidump.

Question:
Can anyone give me an example of how this can be done?

Your Answer

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

Browse other questions tagged or ask your own question.