3

I want to add a feature to a polygon vector layer in QGIS.

I have:

myLayer.featureAdded.connect(doSomething)

And when I click on a button:

iface.setActiveLayer(myLayer)
myLayer.startEditing()
iface.actionAddFeature().trigger()

So when the button is clicked I can draw a polygon on the canvas. When I end the drawing the usual edit form appears.

Is there a way to prevent it from opening or to close it immediately? (I want to edit the attributes programmatically in doSomething).

1
3

You can deactivate the data entry form in the QGIS options. Not sure where to find this option in pyQGIS.


enter image description here

4
  • maybe like that : Turning "ON": QSettings().setValue( '/qgis/digitizing/disable_enter_attribute_values_dialog', True ) Turning "OFF": QSettings().setValue( '/qgis/digitizing/disable_enter_attribute_values_dialog', False ) thanks to @José-Gabriel Nov 1 '17 at 15:17
  • 1
    The configuration can be set for the layer only from pyqgis with myLayer.setFeatureFormSuppress(1)
    – vwrobel
    Nov 2 '17 at 2:30
  • @vwrobel Which is deprecated and not available in QGIS 3.x. github.com/qgis/QGIS/blob/master/doc/api_break.dox#L2572 Nov 14 '17 at 15:40
  • 1
    For reference, using QGIS 3.x, you would need to do this: form_config = layer.editFormConfig() form_config.setSuppress(QgsEditFormConfig.SuppressOn) layer.setEditFormConfig(form_config) Nov 14 '17 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.