I work on many projects in QGIS where the same type of maps are created for the final reports. Each map has a particular style, and the layers always retain the same structure across projects.

Each map is a group in QGIS which I turn on when outputting the layout. To bring styles across I simply open a previous project and for each layer copy all style categories across, but it is very repetitive.

Apart from creating a pre-styled 'template' which I can save as a new project each time, is there a bulk way of copying styles across projects/maps, such as a QML file for many styles? Perhaps a plugin is available?

1 Answer 1


Save the styles as qml files, adjust the keys of the style_dict to match your layer names, and the values the paths to the style files:

style_dict =   {"index_100km":"/home/bera/Desktop/gistest/index_100km_style.qml",

for layer in QgsProject.instance().mapLayers().values(): #For all layers in layer tree
    if layer.name() in style_dict: #Check if it's in the style_dict
        stylefile = style_dict[layer.name()] #If it is, fetch the path to the style file
        {'INPUT':layer,'STYLE':stylefile}) #Apply the style

enter image description here

The same result can be accomplished using the modeler:

enter image description here

  • You can also use layer.loadNamedStyle(stylefile) instead of processing.run() Commented May 12 at 11:38
  • Will this work if the same layers are repeated in different groups? I have quite a few maps per project so I group them and turn each group on before outputting the layout.
    – Josh
    Commented May 26 at 11:11
  • I think so, have you tried and it didnt work?
    – Bera
    Commented May 26 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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