Hello Team,
I know that the UI must not be updated from the QgsTask.run() method. Are there
any similar restrictions on loading QgsVectorLayer from a file or creating new
layers from QgsTask.run() ?
I find that some operations on a GPKG layer do not work as expected when run
from a QgsTask.
These operations work fine when they are done from a foreground thread.
Example:
class MyTask(QgsTask)
...
def run(self):
self.layer = QgsVectorLayer("geom.gpkg", "test_geom", "ogr")
def finished(self, res):
if self.layer.isValid():
QgsProject.instance().addMapLayer(self.layer) # Layer loads, but
attribute table is not editable
--------------------------
On the other hand, the following works just as expected. The attribute table is
editable.
layer = QgsVectorLayer("geom.gpkg", "test_geom", "ogr")
QgsProject.instance().addMapLayer(layer) # Layer loads and attribute table is
editable.
What are the best practices for working with a QgsVectorLayer from within a
QgsTask?
Regards,
Tej
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer