I want to write a plugin in QGIS3 that changes the style of a vector layer. The styles to be loaded are saved in a postgres database in the table 'layer_styles'.
Therefore, I tried using
uri=QgsDataSourceUri() uri.setConnection("host_name", "5432", "database_name", "user", "xxx") uri.setSchema("public") uri.setSql("SELECT styleqml FROM public.layer_styles WHERE stylename='nice'") self.layer.loadNamedStyle(uri.uri(False))
This doesn't give me an error but nothing happens.
Do I only 'load' the style and not apply it?
My layer is of class
QgsVectorLayer, could this be the problem?
Is there another way of loading and applying the style to the vector layer?