[QGIS-Developer] QGIS attribute form - changing values with Python of disabled widgets

Andreas Neumann a.neumann at carto.net
Mon Nov 7 06:42:43 PST 2022


Hi,

I have a QGIS form with a number of widgets that are set to "disabled". 
I don't want the user to change these values manually, but they should 
be updated by a Python action "on demand". Hence I set the editable 
state of these widgets to False.

Now I noticed that while I can change values in the widgets with my 
Python action, the values are not stored when the editable state is set 
to "False". As soon as I set the editable state to "True", then my 
Python action works fine and the values are correctly stored.

I tried with two approaches:

QgsAttributeForm.changeAttribute()

and

QgsWidget.setValue()

Both of these work fine when editable state is enabled, but not, when 
they are disabled.

Is there any way to also change attribute values when the editable state 
of a widget is set to False?

Thanks,

Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20221107/23580538/attachment-0001.htm>


More information about the QGIS-Developer mailing list