Bug report #11395
QgsAttributeForm not entering edit mode
|Affected QGIS version:||2.4.0||Regression?:||No|
|Operating System:||OSX||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||end of life|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||19678|
A valid UI file and Init function have been specified via layer.setEditForm and layer.setEditFormInit
1. User enters Attribute Table
2. Selects edit mode
3. Switches to Open form
Form opens but is not editable
Alternative flow 1.
2. Switch to open Form
3. Select edit mode
Form is still not in edit mode
Alternative flow 2.
1. Select layer
2. Select feature
3. Select "Toggle Editing" to enable editing
3. Click 'i' Identify Features
4. Edit Form opens (if configured to open directly) but dialog is not editable.
Finally, to force the form to open as editable it is necessary to programmatically start editing then directly call openFeatureForm:
iface.openFeatureForm(layer, feature, True)
Example available using this plugin:
#1 Updated by Matthias Kuhn almost 5 years ago
- Status changed from Open to Feedback
In your screenshot you did not select a feature. We could think about pre-selecting the first feature to make it more intuitive.
I recently discussed with Alexandre about this (or a similar issue) and realized, that we were talking about two different things.
He wanted a feature form to edit feature attributes without saving them to the feature but just to get an edited feature back (in a python plugin). Is this your use-case as well?
#2 Updated by Andrew McClure almost 5 years ago
There are a number of use cases.
1. Be able to enter edit mode using a custom form from the Attribute Table dialog. Currently the custom feature form only opens as not editable regardless of layer state
2. Be able to enter an editable OR non editable version of the feature by selecting 'i' from the layer itself - and respecting the layer's edit value
3. Programmatically be able to edit the feature by calling openFeatureForm with an existing issue. I have found a work around for this and posted it to the mailing list and included it below:
- Use a feature saved say to a widget's data properties.
- On a callback, copy the attributes the current layer.getFeatures() to ensure the old feature is in sync.
- Make the layer editable and pass the "updated" feature to the openFeatureForm
#3 Updated by Matthias Kuhn almost 5 years ago
Is there something wrong with the first two scenarios? These were working nicely last time I looked.
Related to python code, there was a problem when directly using QgsAttributeDialog and toggling edit mode after opening the dialog. This has been solved in a3dad24. openFeatureForm should have always worked.
Can you clarify what you are trying to do, what is not working, point to some sample code (exact locations, not a whole plugin. Most appreciated would be a minimal working example that can be run from the python console). It could also be related to the provider you use or if a subset string is set on your layer.
#4 Updated by Andrew McClure almost 5 years ago
I would certainly love this to be a problem with my own code!
Unfortunately, for you to view the flow/recreate it is not as trivial as running a few lines of code. However, I can point to the places in my code. And there is also the feature form available from the AttributeTable if you simply run the plugin TelemetryLayer and follow the steps to create a new Telemetry Layer.
As for what is not working/what we are trying to do, this should be clear from my last issue update. I simply want the edit mode of the layer to be respected with regards opening a custom feature form.
As to the code, here are the critical bits:
1. This is the custom edit form init:
2. Here is the class that gets invoked and performs the dialog logic. You can see the debug statement showing the editable state.
3. Here is the code that programmatically opens a featureForm using a feature stored in a QWidget which has been refreshed.
(Note by changing the feature that is passed to the one that is returned from Layer.getFeature, the dialog fails to open in edit mode regardless of the layer's state.)
#7 Updated by Giovanni Manghi 6 months ago
- Resolution set to end of life
- Status changed from Open to Closed
End of life notice: QGIS 2.18 LTR