Class: QgsDualView¶
This widget is used to show the attributes of a set of features of a
QgsVectorLayer
. The attributes can be edited. It supports
two different layouts: the table layout, in which the attributes for the
features are shown in a table and the editor layout, where the features
are shown as a selectable list and the attributes for the currently
selected feature are shown in a form.
Class Hierarchy¶
Base classes¶
Methods
The config used for the attribute table. |
|
Cancel the progress dialog (if any) |
|
Copy the content of the selected cell in the clipboard. |
|
Returns the number of features on the layer. |
|
Sets the expression and Updates the filtered features in the filter model. |
|
Gets the filter mode |
|
Returns the number of features which are currently visible, according to the filter restrictions |
|
Gets a list of currently visible feature ids. |
|
Has to be called to initialize the dual view. |
|
Returns the model which has the information about all features (not only filtered) |
|
Called in embedded forms when an attribute value in the parent form has changed. |
|
saveEditChanges |
|
Set the attribute table config which should be used to control the appearance of the attribute table. |
|
Set the current edit selection in the AttributeEditor mode. |
|
Set the feature selection model |
|
Set the filter mode |
|
Set a list of currently visible features |
|
Sets whether multi edit mode is enabled. |
|
Set the request |
|
Toggle the selectedOnTop flag. |
|
Set the expression used for sorting the table and feature list. |
|
Change the current view mode. |
|
Gets the expression used for sorting the table and feature list. |
|
Returns the table view |
|
Toggles whether search mode should be enabled in the form. |
|
Returns the current view mode. |
Static Methods
Returns the list of required attributes according to the attribute table configuration of the layer, only visible attributes and virtual fields referenced fields are returned. |
Signals
Emitted whenever the display expression is successfully changed |
|
Emitted whenever the filter changes |
|
Emitted when a filter expression is set using the view. |
|
Emitted when the form changes mode. |
|
Emitted when selecting context menu on the feature list to create the context menu individually |
Attributes
- class qgis.gui.QgsDualView[source]¶
Bases:
QStackedWidget
- __init__(parent: QWidget | None = None)
Constructor
- Parameters:
parent (Optional[QWidget] = None) – The parent widget
- AttributeEditor = 1¶
- AttributeTable = 0¶
- class FeatureListBrowsingAction¶
Bases:
int
- NoAction = 0¶
- PanToFeature = 1¶
- class ViewMode¶
Bases:
int
- ZoomToFeature = 2¶
- attributeTableConfig(self) QgsAttributeTableConfig [source]¶
The config used for the attribute table.
- Return type:
- Returns:
The config used for the attribute table.
- signal displayExpressionChanged(expression: str)[source]¶
Emitted whenever the display expression is successfully changed
- Parameters:
expression (str) – The expression that was applied
- featureCount(self) int [source]¶
Returns the number of features on the layer.
- Return type:
int
- Returns:
Number of features
- signal filterExpressionSet(expression: str, type: QgsAttributeForm.FilterType)[source]¶
Emitted when a filter expression is set using the view.
- Parameters:
expression (str) – filter expression
type (QgsAttributeForm.FilterType) – filter type
- filterFeatures(self, filterExpression: QgsExpression, context: QgsExpressionContext)[source]¶
Sets the expression and Updates the filtered features in the filter model. It is called when the filter expression changed.
Added in version 3.10.3.
- Parameters:
filterExpression (QgsExpression)
context (QgsExpressionContext)
- filterMode(self) QgsAttributeTableFilterModel.FilterMode [source]¶
Gets the filter mode
- Return type:
- Returns:
the filter mode
- filteredFeatureCount(self) int [source]¶
Returns the number of features which are currently visible, according to the filter restrictions
- Return type:
int
- Returns:
Number of features
- signal formModeChanged(mode: QgsAttributeEditorContext.Mode)[source]¶
Emitted when the form changes mode.
- Parameters:
mode (QgsAttributeEditorContext.Mode) – new mode
- init(self, layer: QgsVectorLayer | None, mapCanvas: QgsMapCanvas | None, request: QgsFeatureRequest = QgsFeatureRequest(), context: QgsAttributeEditorContext = QgsAttributeEditorContext(), loadFeatures: bool = True, showFirstFeature: bool = True)[source]¶
Has to be called to initialize the dual view.
- Parameters:
layer (Optional[QgsVectorLayer]) – The layer which should be used to fetch features
mapCanvas (Optional[QgsMapCanvas]) – The mapCanvas (used for the FilterMode
QgsAttributeTableFilterModel
.ShowVisible)request (
QgsFeatureRequest
= QgsFeatureRequest()) – Use a modified request to limit the shown featurescontext (
QgsAttributeEditorContext
= QgsAttributeEditorContext()) – The context in which this view is shownloadFeatures (bool = True) – whether to initially load all features into the view. If set to
False
, limited features can later be loaded usingsetFilterMode()
showFirstFeature (bool = True) – whether to initially show the first feature form upon initializing the dual view
- masterModel(self) QgsAttributeTableModel | None [source]¶
Returns the model which has the information about all features (not only filtered)
- Return type:
Optional[QgsAttributeTableModel]
- Returns:
The master model
- parentFormValueChanged(self, attribute: str | None, value: Any)[source]¶
Called in embedded forms when an
attribute
value
in the parent form has changed.Notify the form widgets that something has changed in case they have filter expression that depend on the parent form scope.
Added in version 3.14.
- Parameters:
attribute (Optional[str])
value (Any)
- static requiredAttributes(layer: QgsVectorLayer | None) List[int] [source]¶
Returns the list of required attributes according to the attribute table configuration of the
layer
, only visible attributes and virtual fields referenced fields are returned.Added in version 3.32.
- Parameters:
layer (Optional[QgsVectorLayer])
- Return type:
List[int]
- saveEditChanges(self) bool [source]¶
- saveEditChanges(None) None
- Return type:
bool
- Returns:
True
if the saving was OK.False
is possible due to connected validation logic.
- setAttributeTableConfig(self, config: QgsAttributeTableConfig)[source]¶
Set the attribute table config which should be used to control the appearance of the attribute table.
- Parameters:
config (QgsAttributeTableConfig)
- setCurrentEditSelection(self, fids: Any)[source]¶
Set the current edit selection in the AttributeEditor mode.
- Parameters:
fids (Any) – A list of edited features (Currently only one at a time is supported)
- setFeatureSelectionManager(self, featureSelectionManager: QgsIFeatureSelectionManager | None)[source]¶
Set the feature selection model
- Parameters:
featureSelectionManager (Optional[QgsIFeatureSelectionManager]) – the feature selection model
- setFilterMode(self, filterMode: QgsAttributeTableFilterModel.FilterMode)[source]¶
Set the filter mode
- Parameters:
filterMode (QgsAttributeTableFilterModel.FilterMode)
- setFilteredFeatures(self, filteredFeatures: Any)[source]¶
Set a list of currently visible features
- Parameters:
filteredFeatures (Any) – A list of feature ids
Deprecated since version 3.40: Since filterFeatures is handled in the attribute filter model itself.
- setMultiEditEnabled(self, enabled: bool)[source]¶
Sets whether multi edit mode is enabled.
- Parameters:
enabled (bool)
- setRequest(self, request: QgsFeatureRequest)[source]¶
Set the request
- Parameters:
request (QgsFeatureRequest) – The request
- setSelectedOnTop(self, selectedOnTop: bool)[source]¶
Toggle the selectedOnTop flag. If enabled, selected features will be moved to top.
- Parameters:
selectedOnTop (bool) –
True
: Show selected features on top.False
: Use defined sorting column.
- setSortExpression(self, sortExpression: str | None, sortOrder: Qt.SortOrder = Qt.AscendingOrder)[source]¶
Set the expression used for sorting the table and feature list.
- Parameters:
sortExpression (Optional[str])
sortOrder (Qt.SortOrder = Qt.AscendingOrder)
- setView(self, view: QgsDualView.ViewMode)[source]¶
Change the current view mode.
- Parameters:
view (QgsDualView.ViewMode) – The view mode to set
See also
- signal showContextMenuExternally(menu: QgsActionMenu, fid: QgsFeatureId)[source]¶
Emitted when selecting context menu on the feature list to create the context menu individually
- Parameters:
menu (QgsActionMenu) – context menu
fid (QgsFeatureId) – feature id of the selected feature
- sortExpression(self) str [source]¶
Gets the expression used for sorting the table and feature list.
- Return type:
str
- tableView(self) QgsAttributeTableView | None [source]¶
Returns the table view
- Return type:
Optional[QgsAttributeTableView]
- Returns:
The table view
- toggleSearchMode(self, enabled: bool)[source]¶
Toggles whether search mode should be enabled in the form.
- Parameters:
enabled (bool) – set to
True
to switch on search mode
- view(self) QgsDualView.ViewMode [source]¶
Returns the current view mode.
See also
- Return type: