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¶
- 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[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- featureCount(self) int[source]¶
Returns the number of features on the layer.
- Return type:
int
- Returns:
Number of features
- signal filterChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal filterExpressionSet[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- 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[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- 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
attributevaluein 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()
- Return type:
bool
- Returns:
Trueif the saving was OK.Falseis 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[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- 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
Trueto switch on search mode
- view(self) QgsDualView.ViewMode[source]¶
Returns the current view mode.
See also
- Return type: