Hi Matthias,

Do you mean disabling them with a Python init code and QgsWidget.setEnabled(False) - right?

Just tried it - and it seems to work ;-)

Thanks for the hint!

Andreas

On 2022-11-07 15:46, Matthias Kuhn wrote:

Hi Andreas,

How about going the other way around and leaving them as editable in the config and disabling the widget via python instead?

Matthias

On Mon, Nov 7, 2022 at 3:42 PM Andreas Neumann via QGIS-Developer <qgis-developer@lists.osgeo.org> wrote:

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 _______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[1]

Best of Swiss Enterprise App-Award for QField [1] - Hold the power of QGIS in your hand - get it now [2]



Links:
------
[1] https://www.opengis.ch/2022/11/03/best-of-swiss-enterprise-app-award-for-qfield/
[2] https://qfield.org/get
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to