[QGIS-Developer] Deactivate QgsRasterLayer CRS prompt

KOHLMANN Hannes H.KOHLMANN at ove.at
Tue Mar 20 11:30:09 PDT 2018


Hello again!

I do the following to add a QgsRasterLayer:
l = QgsRasterLayer("/path/file.dat", "Density")

Now I am struggling with a problem, that has somehow always the same suggested solution in all fora, namely to get rid of the prompt that appears
when adding a QgsRasterLayer, by using:
s = QSettings()
oldValidation = s.value( "/Projections/defaultBehaviour" )
s.setValue( "/Projections/defaultBehaviour", "useGlobal" ) # it doesn't matter what property to take, be it "useProject", "useGlobal" or "prompt" ...
... before adding the layer. But on my Linux environment, this does not work - and also not on my collegue's Windows system.
Has there something changed with the usage of QSettings w.r.t. to its usage in QGIS in the step from QGIS 2 to QGIS 3?

(Re)setting the layer CRS of course works normally and works as expected!

l.setCrs(QgsCoordinateReferenceSystem(31287))
QgsProject.instance().addMapLayer(l)

Do you have any suggestions, how I could tackle the problem?

Thank you very much in advance!

Best regards,
Hannes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180320/048884a3/attachment-0001.html>


More information about the QGIS-Developer mailing list