class documentation

class TableModel(QAbstractTableModel):

Constructor: TableModel(parent, data, row_keys, col_keys, ...)

View In Hierarchy

TableModel class.

Method __init__ Initializes a table model.
Method columnCount Gets the number of columns. Note: Enabling allow_delete adds an extra column for the row delete buttons.
Method data Gets a cell value.
Method flags Gets the flags for a cell.
Method headerData Sets the header data.
Method is_widget Checks if the cell is a widget button.
Method rowCount Gets the number of rows.
Method setData Sets a cell value.
Instance Variable _col_is_widget Undocumented
Instance Variable _col_keys Undocumented
Instance Variable _data Undocumented
Instance Variable _row_keys Undocumented
def __init__(self, parent: QTableView, data: list[list], row_keys: list[str], col_keys: list[str], col_is_widget: list[bool] | None = None):

Initializes a table model.

Parameters
parent:QTableViewQTableView
data:list[list]Data (2D)
row_keys:list[str]List of vertical header strings
col_keys:list[str]List of horizontal header strings
col_is_widget:list[bool] | NoneIndicates columns contains only widgets instead of only data (may be None for data-only)
def columnCount(self, parent: QtCore.QModelIndex = None):

Gets the number of columns. Note: Enabling allow_delete adds an extra column for the row delete buttons.

Returns
Number of columns
def data(self, index: QtCore.QModelIndex, role: int = Qt.DisplayRole) -> QVariant:

Gets a cell value.

Parameters
index:QtCore.QModelIndexCell index
role:intData role
Returns
QVariantCell value
def flags(self, index: QtCore.QModelIndex) -> int:

Gets the flags for a cell.

Parameters
index:QtCore.QModelIndexCell index
Returns
intCell flags
def headerData(self, section: int, orientation: Qt.Orientation, role: int = Qt.DisplayRole) -> QVariant:

Sets the header data.

Parameters
section:intRow or column
orientation:Qt.OrientationOrientation
role:intData role
Returns
QVariantUndocumented
def is_widget(self, index: QtCore.QModelIndex) -> bool:

Checks if the cell is a widget button.

Parameters
index:QtCore.QModelIndexCell index
Returns
boolTrue if the cell is a widget, False otherwise
def rowCount(self, parent: QtCore.QModelIndex = None):

Gets the number of rows.

Returns
Number of rows
def setData(self, index: QtCore.QModelIndex, value: Any, role: int = Qt.EditRole) -> bool:

Sets a cell value.

Parameters
index:QtCore.QModelIndexCell index
value:AnyCell value
role:intData role
Returns
boolTrue if successful, False otherwise
_col_is_widget =

Undocumented

_col_keys =

Undocumented

_data =

Undocumented

_row_keys =

Undocumented