[QGIS-Developer] Deactivate QgsRasterLayer CRS prompt

Nyall Dawson nyall.dawson at gmail.com
Tue Mar 20 14:53:26 PDT 2018


On 21 March 2018 at 04:30, KOHLMANN Hannes <H.KOHLMANN at ove.at> wrote:
> 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?
>

That should still work.

Try using QgsSettings instead (but I don't think this should be necessary):

s = QgsSettings()


Nyall


More information about the QGIS-Developer mailing list