[QGIS-Developer] reload attribute table does not work for attribute changed by dataProvider

Matthias Kuhn matthias at opengis.ch
Wed Jun 13 02:45:17 PDT 2018


Hi Ethan

On 06/13/2018 11:18 AM, Zhang Qun wrote:
> Hi everyone, i"m using QGIS2.18, and trying to change feature attributes
> using the following two methods:
> 
> *dataProvider:*
> 
> |attrs ={0:"hello",1:123}layer.dataProvider().changeAttributeValues({fid
> :attrs })|
> 
> *layer object:*
> 
> |layer.startEditing()layer.changeAttributeValue(fid,fieldIndex,value)layer.commitChanges()|
> 
> I keep the attribute table open, and monitor the changes. The first
> method dataProvider is not able to update the attribute table on the
> fly, even the "reload table" button on the top menu of the table does
> not work. I have to re-open the table to see the changes. The second
> method is working, the attribute table gets instantly updated.
> 
> I would like to stay with the dataProvider method but not sure how to
> get instantly updated attribute table?

The provider's dataChanged() signal needs to be emitted, I think you can
directly emit that or call `dataProvider().forceReload()`.

Out of curiosity, why would you like to stay with the dataProvider  method?

Bests
Matthias


> 
> Thanks.
> 
> Best regards,
> Ethan
> 
> 
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> 


More information about the QGIS-Developer mailing list