Class: QgsAbstractDbTableModel

Pure virtual model class for results in a database source widget selector.

Added in version 3.24.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: columns(), defaultSearchColumn(), setSql()

Class Hierarchy

Inheritance diagram of qgis.core.QgsAbstractDbTableModel

Base classes

QStandardItemModel

QAbstractItemModel

QObject

Abstract Methods

columns

Returns the list of columns in the table

defaultSearchColumn

Returns the index of the column used by default to filter the results (probably the table name column if it exists)

setSql

Sets an sql statement that belongs to a cell specified by a model index

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsAbstractDbTableModel. See the FAQ for more details.

searchableColumn

Returns if the column should be searchable at the given index

class qgis.core.QgsAbstractDbTableModel[source]

Bases: QStandardItemModel

__init__(parent: QObject | None = None)

Constructor

Parameters:

parent (Optional[QObject] = None)

abstract columns(self) List[str][source]

Returns the list of columns in the table

Return type:

List[str]

abstract defaultSearchColumn(self) int[source]

Returns the index of the column used by default to filter the results (probably the table name column if it exists)

Return type:

int

virtual searchableColumn(self, column: int) bool[source]

Returns if the column should be searchable at the given index

Parameters:

column (int)

Return type:

bool

abstract setSql(self, index: QModelIndex, sql: str | None)[source]

Sets an sql statement that belongs to a cell specified by a model index

Parameters:
  • index (QModelIndex)

  • sql (Optional[str])