Class: QgsAttributeForm¶
Class Hierarchy¶
Base classes¶
Methods
Takes ownership |
|
The aggregate filter is only useful if the form is in AggregateFilter mode. |
|
Call this to change the content of a given attribute. |
|
Changes the geometry of the feature attached to the form. |
|
Returns the feature that is currently displayed in the form with all the changes received on editing the values in the widgets. |
|
Disconnects the button box (OK/Cancel) from the accept/resetValues slots If this method is called, you have to create these connections from outside |
|
Displays a warning message in the form message bar |
|
Returns if the form is currently in editable mode. |
|
Intercepts keypress on custom form (escape should not close it) |
|
Hides the button box (OK/Cancel) and enables auto-commit |
|
Returns the layer for which this form is shown |
|
Returns the current mode of the form. |
|
Returns |
|
Is called in embedded forms when an attribute value in the parent form has changed to newValue. |
|
reload current feature |
|
Resets the search/filter form values. |
|
Sets all values to the values of the current feature |
|
Save all the values from the editors to the layer. |
|
Save all the values from the editors to the layer. |
|
Sets the edit command message (Undo) that will be used when the dialog is accepted |
|
Sets an additional expression context scope to be used for calculations in this form. |
|
Update all editors to correspond to a different feature. |
|
Sets the message bar to display feedback from the form in. |
|
Sets the current mode of the form. |
|
Sets all feature IDs which are to be edited if the form is in multiedit mode |
|
Shows the button box (OK/Cancel) and disables auto-commit |
Signals
Notifies about changes of attributes, this signal is not emitted when the value is set back to the original one. |
|
Emitted when the user selects the close option from the form's button bar. |
|
Emitted when a feature is changed or added |
|
Emitted when a filter expression is set using the form. |
|
Emitted when the user chooses to flash a filtered set of features. |
|
Emitted when the form changes mode. |
|
Emitted when the user chooses to open the attribute table dialog with a filtered set of features. |
|
Notifies about changes of attributes |
|
Emitted when the user chooses to zoom to a filtered set of features. |
Attributes
- class qgis.gui.QgsAttributeForm(vl: QgsVectorLayer | None, feature: QgsFeature = QgsFeature(), context: QgsAttributeEditorContext = QgsAttributeEditorContext(), parent: QWidget | None = None)[source]¶
Bases:
QWidget
- AddFeatureMode = 1¶
- AggregateSearchMode = 4¶
- FilterAnd = 1¶
- FilterOr = 2¶
- class FilterType¶
Bases:
int
- IdentifyMode = 5¶
- class Mode¶
Bases:
int
- MultiEditMode = 2¶
- ReplaceFilter = 0¶
- SearchMode = 3¶
- SingleEditMode = 0¶
- addInterface(self, iface: QgsAttributeFormInterface | None)[source]¶
Takes ownership
- Parameters:
iface (Optional[QgsAttributeFormInterface])
- aggregateFilter(self) str [source]¶
The aggregate filter is only useful if the form is in AggregateFilter mode. In this case it will return a combined expression according to the chosen filters on all attribute widgets.
- Return type:
str
- signal attributeChanged[source]¶
Notifies about changes of attributes, this signal is not emitted when the value is set back to the original one.
- Parameters:
attribute – The name of the attribute that changed.
value – The new value of the attribute.
Deprecated since version 3.0.
- changeAttribute(self, field: str | None, value: Any, hintText: str | None = '')[source]¶
Call this to change the content of a given attribute. Will update the
- Parameters:
field (Optional[str])
value (Any)
hintText (Optional[str] = '')
- QgsAttributeForm.changeAttribute(s) related to this field.
changeAttribute(s) related to this field.
- Parameters:
field (Optional[str]) – The field to change
value (Any) – The new value
hintText (Optional[str] = '') – A hint text for non existent joined features
- changeGeometry(self, geometry: QgsGeometry)[source]¶
Changes the
geometry
of the feature attached to the form.Added in version 3.30.
- Parameters:
geometry (QgsGeometry)
- currentFormFeature(self) QgsFeature [source]¶
Returns the feature that is currently displayed in the form with all the changes received on editing the values in the widgets.
Added in version 3.16.
- Return type:
- disconnectButtonBox(self)[source]¶
Disconnects the button box (OK/Cancel) from the accept/resetValues slots If this method is called, you have to create these connections from outside
- displayWarning(self, message: str | None)[source]¶
Displays a warning message in the form message bar
- Parameters:
message (Optional[str]) – message string
See also
Added in version 3.12.
- editable(self) bool [source]¶
Returns if the form is currently in editable mode.
- Return type:
bool
- Returns:
Editable mode of this form
- eventFilter(self, object: QObject | None, event: QEvent | None) bool [source]¶
Intercepts keypress on custom form (escape should not close it)
- Parameters:
object (Optional[QObject]) – The object for which the event has been sent
event (Optional[QEvent]) – The event which is being filtered
- Return type:
bool
- Returns:
True
if the event has been handled (key was ESC)
- feature(self) QgsFeature ¶
- Return type:
- signal featureSaved(feature: QgsFeature)[source]¶
Emitted when a feature is changed or added
- Parameters:
feature (QgsFeature)
- signal filterExpressionSet(expression: str, type: QgsAttributeForm.FilterType)[source]¶
Emitted when a filter expression is set using the form.
- Parameters:
expression (str) – filter expression
type (QgsAttributeForm.FilterType) – filter type
- signal flashFeatures(filter: str)[source]¶
Emitted when the user chooses to flash a filtered set of features.
- Parameters:
filter (str)
- hideButtonBox(self)[source]¶
Hides the button box (OK/Cancel) and enables auto-commit
Note
set Embed in
QgsAttributeEditorContext
in constructor instead
- layer(self) QgsVectorLayer | None [source]¶
Returns the layer for which this form is shown
- Return type:
Optional[QgsVectorLayer]
- Returns:
Layer
- mode(self) QgsAttributeEditorContext.Mode [source]¶
Returns the current mode of the form.
See also
- Return type:
- signal modeChanged(mode: QgsAttributeEditorContext.Mode)[source]¶
Emitted when the form changes mode.
- Parameters:
mode (QgsAttributeEditorContext.Mode) – new mode
- needsGeometry(self) bool [source]¶
Returns
True
if any of the form widgets need feature geometryAdded in version 3.20.
- Return type:
bool
- signal openFilteredFeaturesAttributeTable(filter: str)[source]¶
Emitted when the user chooses to open the attribute table dialog with a filtered set of features.
Added in version 3.24.
- Parameters:
filter (str)
- parentFormValueChanged(self, attribute: str | None, newValue: Any)[source]¶
Is called in embedded forms when an
attribute
value in the parent form has changed tonewValue
.Notify the form widgets that something has changed in case they have filter expressions that depend on the parent form scope.
Added in version 3.14.
- Parameters:
attribute (Optional[str])
newValue (Any)
- save(self) bool [source]¶
Save all the values from the editors to the layer.
- Return type:
bool
- Returns:
True
if successful
- saveWithDetails(self)[source]¶
Save all the values from the editors to the layer.
- Returns:
True
if save was successfulerror: an explanatory error message if an error occurs while saving the form.
Added in version 3.18.
- setEditCommandMessage(self, message: str | None)[source]¶
Sets the edit command message (Undo) that will be used when the dialog is accepted
- Parameters:
message (Optional[str]) – The message
- setExtraContextScope(self, extraScope: QgsExpressionContextScope | None)[source]¶
Sets an additional expression context scope to be used for calculations in this form.
Added in version 3.16.
- Parameters:
extraScope (Optional[QgsExpressionContextScope])
- setFeature(self, feature: QgsFeature)[source]¶
Update all editors to correspond to a different feature.
- Parameters:
feature (QgsFeature) – The feature which will be represented by the form
- setMessageBar(self, messageBar: QgsMessageBar | None)[source]¶
Sets the message bar to display feedback from the form in. This is used in the search/filter mode to display the count of selected features.
- Parameters:
messageBar (Optional[QgsMessageBar]) – target message bar
- setMode(self, mode: QgsAttributeEditorContext.Mode)[source]¶
Sets the current mode of the form.
- Parameters:
mode (QgsAttributeEditorContext.Mode) – form mode
See also
- setMultiEditFeatureIds(self, fids: Any)[source]¶
Sets all feature IDs which are to be edited if the form is in multiedit mode
- Parameters:
fids (Any) – feature ID list
- showButtonBox(self)[source]¶
Shows the button box (OK/Cancel) and disables auto-commit
Note
set Embed in
QgsAttributeEditorContext
in constructor instead
- signal widgetValueChanged(attribute: str, value: object, attributeChanged: bool)[source]¶
Notifies about changes of attributes
- Parameters:
attribute (str) – The name of the attribute that changed.
value (object) – The new value of the attribute.
attributeChanged (bool) – If
True
, it corresponds to an actual change of the feature attribute