I have a function whothat uses a layer already styled using another function and saves it as a gpkg.gpkg
and I want to save the style in that gpkg.gpkg
:
def saving_gpkg(styled_layer):
options = QgsVectorFileWriter.SaveVectorOptions()
options.driverName = "GPKG"
QgsVectorFileWriter.writeAsVectorFormatV2(styled_layer, "nice_filename", QgsCoordinateTransformContext(), options)
styled_layer.saveStyleToDatabase("polygon", "style automatically created", True, "")
def saving_gpkg(styled_layer):
options = QgsVectorFileWriter.SaveVectorOptions()
options.driverName = "GPKG"
QgsVectorFileWriter.writeAsVectorFormatV2(styled_layer, "nice_filename", QgsCoordinateTransformContext(), options)
styled_layer.saveStyleToDatabase("polygon", "style automatically created", True, "")
The gpkg.gpkg
is created, but if I open the created file, it doesn't have the defined style, just a random singlesymbolsingle symbol. I'm missing something?