I want to use the QGIS startup.py to set up some configurations. I want to set the following options in the startup.py:
- CRS for project - use a default CRS: EPSG 25833
- CRS for layer - default CRS for layers EPSG: 25833
- use roxy for web access
Therefore I use the following code:
from qgis.core import QgsProject, QgsSettings, QgsCoordinateReferenceSystem
# set CRS for projects EPSG:25833
QgsProject.instance().setCrs(QgsCoordinateReferenceSystem('EPSG:25833'))
# set CRS for new layers EPSG:25833
QgsSettings().setValue('/Projections/defaultBehavior', 'useProject')
QgsSettings().setValue('/Projections/layerDefaultCrs', 'EPSG:25833')
QgsSettings().setValue('/Projections/projectDefaultCrs', 'EPSG:25833')
# enable proxy for web access
QgsSettings().setValue('/Proxy/proxyEnabled', True)
# necessary, otherwise the window for saving projects appears at startup
QgsProject.instance().setDirty(False)
The settings for the proxy and new layers work, but it does not work for new projects. New projects dont use the CRS EPSG 25833