2

I have a folder with ~100 QGIS-style files (.qml). Is it possible to tell QGIS that whenever I load a layer which has the same name as one of the .qml files apply that style instead of giving the layer a random color?

We have layers in each of our customers' folders, always with the same name (e.g. "Trees") so .qlr is not an option.

I know I can do it with a Python script, but I do not want to execute it every time I add a new layer. Maybe it is possible to trigger the script automatically everytime a layer is added?

Taras
  • 32,823
  • 4
  • 66
  • 137
sn1ks
  • 2,982
  • 12
  • 28
  • 2
    Why not using Layer Definition file (.qlr) rather than .qml ? this seem more adequate for your situation (https://gis.stackexchange.com/questions/330532/difference-between-layer-definition-file-qlr-and-qgis-layer-style-file-qml). In the meantime this (https://gis.stackexchange.com/questions/338626/loading-layer-styles-qml-file-is-there-a-shortcut-or-toolbar-icon) could probably adapted to your current situation. – J.R Jul 05 '23 at 08:11
  • we have around 50 customers with the same basic datastructure. for example there is one file called "Trees.shp" in each customer's folder. whenever i open any custoomers "tree" file, i do not want to apply the style (which is for all customers the same) manually - so .qlr seems not to be the right choice for me. I'll check out the second link you provided! – sn1ks Jul 05 '23 at 08:29
  • 1
    With .qlr, you open the qlr file, you don't open the shapefile, the qlr references the shapefile, it's not a case of applying any style manually – nmtoken Jul 05 '23 at 09:07
  • 1
    @sn1ks You should provide these precision in your question by editing it. So yes it seem that adapting the script in the linked answer to automate thing bis the way to go in your case – J.R Jul 05 '23 at 09:37

0 Answers0