magneticalc.QTableView2.TableModel

# ``magneticalc`.`QTableView2`.`TableModel``

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: `QTableView` | QTableView
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] | None` | Indicates 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.QModelIndex` | Cell index
role: `int` | Data role

Returns
`QVariant` | Cell value

def flags(self, index: `QtCore.QModelIndex`) -> `int`:

Gets the flags for a cell.

Parameters
index: `QtCore.QModelIndex` | Cell index

Returns
`int` | Cell flags

def headerData(self, section: `int`, orientation: `Qt.Orientation`, role: `int` = Qt.DisplayRole) -> `QVariant`:

Sets the header data.

Parameters
section: `int` | Row or column
orientation: `Qt.Orientation` | Orientation
role: `int` | Data role

Returns
`QVariant` | Undocumented

def is_widget(self, index: `QtCore.QModelIndex`) -> `bool`:

Checks if the cell is a widget button.

Parameters
index: `QtCore.QModelIndex` | Cell index

Returns
`bool` | True 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.QModelIndex` | Cell index
value: `Any` | Cell value
role: `int` | Data role

Returns
`bool` | True if successful, False otherwise

_col_is_widget =

Undocumented

_col_keys =

Undocumented

_data =

Undocumented

_row_keys =

Undocumented