Is QgsMapLayerRegistry
going to be availabe in pyqgis with QGIS3
When I typed it into the QGIS python console (2.99), python seems to recognize it because it auto-completes qgis.core.QgsMapLayerRegistry
, but then gives an error that it's not there:
Traceback (most recent call last):
File "/usr/lib/python3.5/code.py", line 91, in runcode
exec(code, self.locals)
File "", line 1, in
AttributeError: module 'qgis.core' has no attribute 'QgsMapLayerRegistry'
I tried this with two versions of QGIS 2.99 (one in 01/07 and on in 06/17). Both versions give the same error. import
doesn't work either:
>>>from qgis.core import QgsMapLayerRegistry
Traceback (most recent call last):
File "/usr/lib/python3.5/code.py", line 91, in runcode
exec(code, self.locals)
File "", line 1, in
ImportError: cannot import name 'QgsMapLayerRegistry'
Is QgsMapLayerRegistry
removed in QGIS3?
Answer
Yes it has been removed, but alternatives exist.
Changes of the 3.0 API are listed here:
https://qgis.org/api/api_break.html
QgsMapLayerRegistry
: Its functionality has been moved toQgsProject
.
The main reason is, that QgsMapLayerRegistry is/was a singleton and therefore only a single registry could ever exist. With this constraint removed, major roadblocks are out of the way to implement new things like having multiple projects open side-by-side.
No comments:
Post a Comment