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

Inheritance diagram of qgis.gui.QgsDualView

Base classes

QStackedWidget

QFrame

QWidget

QObject

QPaintDevice

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:

QgsAttributeTableConfig

Returns:

The config used for the attribute table.

cancelProgress(self)[source]

Cancel the progress dialog (if any)

copyCellContent(self)[source]

Copy the content of the selected cell in the clipboard.

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:
filterMode(self) QgsAttributeTableFilterModel.FilterMode[source]

Gets the filter mode

Return type:

QgsAttributeTableFilterModel.FilterMode

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

filteredFeatures(self) Any[source]

Gets a list of currently visible feature ids.

Return type:

Any

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 features

  • context (QgsAttributeEditorContext = QgsAttributeEditorContext()) – The context in which this view is shown

  • loadFeatures (bool = True) – whether to initially load all features into the view. If set to False, limited features can later be loaded using setFilterMode()

  • 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

openConditionalStyles(self)[source]
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()
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

view()

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 True to switch on search mode

view(self) QgsDualView.ViewMode[source]

Returns the current view mode.

See also

setView()

Return type:

QgsDualView.ViewMode