class documentation

class QTableView2(QTableView):

View In Hierarchy

QTableView2 class.
Method __init__ Initializes a table.
Method focusInEvent Gets called when the table gained focus. This highlights the border and selects the last-selected cell (if any).
Method focusOutEvent Gets called when the table lost focus, or when a cell is being edited. When not editing, this clears the selection, triggering on_selection_changed().
Method get_selected_row Returns the currently selected row index.
Method on_combobox_cell_edited Gets called when a combobox cell has been edited.
Method on_data_changed Gets called when the data in a selection changed. Note: Always assuming only a single cell is selected.
Method on_row_deleted Gets called when a row was deleted.
Method on_selection_changed Gets called when the selection changed.
Method select_cell Selects a cell. Any parameter may be left set to None in order to load its value from the selection model.
Method select_last_row Selects the last row.
Method set_data Sets the table contents.
Method set_style Sets this widget's style.
Instance Variable gui Undocumented
Instance Variable _allow_delete Undocumented
Instance Variable _col_keys Undocumented
Instance Variable _col_options Undocumented
Instance Variable _col_types Undocumented
Instance Variable _on_cell_edited Undocumented
Instance Variable _on_row_deleted Undocumented
Instance Variable _on_selection_changed Undocumented
Instance Variable _row_count_minimum Undocumented
Instance Variable _row_prefix Undocumented
def __init__(self, gui, col_keys, col_types=None, col_options=None, row_allow_delete=True, row_count_minimum=0, row_prefix='', on_cell_edited=None, on_selection_changed=None, on_row_deleted=None):
Initializes a table.
Parameters
gui:GUIGUI
col_keys:List[str]List of horizontal header strings
col_types:Optional[Dict]Per-column cell types used for binding cells to configuration. Ordered dictionary of key-value pairs (column key : column type) or None to disable binding. Note: Currently, *only the keys* are used for binding cells to project configuration; the cell options actually determine the cell type, i.e. numerical or combobox.
col_options:Optional[List]Per-column cell options. This determines the cell type, i.e. numerical or combobox. List of options for every column; items may be set to None to use numerical cells.
row_allow_delete:boolEnable to add an extra column for row delete buttons
row_count_minimum:intMinimum number of rows (no further rows can be deleted)
row_prefix:strPer-row prefix used for binding cells to configuration (key = prefix + column key + "_" + row index)
on_cell_edited:Optional[Callable]Set this to make cells editable
on_selection_changed:Optional[Callable]Used to inform the GUI that another row was selected
on_row_deleted:Optional[Callable]Set this to make rows deletable
def focusInEvent(self, _event):
Gets called when the table gained focus. This highlights the border and selects the last-selected cell (if any).
Parameters
_event:QFocusEventQFocusEvent
def focusOutEvent(self, _event):
Gets called when the table lost focus, or when a cell is being edited. When not editing, this clears the selection, triggering on_selection_changed().
Parameters
_event:QFocusEventQFocusEvent
def get_selected_row(self):
Returns the currently selected row index.
Returns
Optional[int]Index of currently selected row (None if none selected)
def on_combobox_cell_edited(self, combobox, row, column):
Gets called when a combobox cell has been edited.
Parameters
combobox:QComboBoxQCombobox
row:intRow index
column:intColumn index
def on_data_changed(self, top_left_index, _bottom_right_index):
Gets called when the data in a selection changed. Note: Always assuming only a single cell is selected.
Parameters
top_left_index:QtCore.QModelIndexModel index of the top left selection bounds
_bottom_right_index:QtCore.QModelIndexModel index of the bottom right selection bounds
def on_row_deleted(self, row):
Gets called when a row was deleted.
Parameters
row:intRow
def on_selection_changed(self, _selected, _deselected):
Gets called when the selection changed.
Parameters
_selected:QItemSelectionCurrently selected QItemSelection
_deselected:QItemSelectionCurrently deselected QItemSelection
def select_cell(self, row=None, col=None):
Selects a cell. Any parameter may be left set to None in order to load its value from the selection model.
Parameters
row:Optional[int]Row
col:Optional[int]Column
def select_last_row(self, focus=True):
Selects the last row.
Parameters
focus:boolEnable to focus the table, disable to explicitly clear the visual selection
def set_data(self, data, row_keys):
Sets the table contents.
Parameters
data:List[List[str]]Data (2D)
row_keys:List[str]List of vertical header strings
def set_style(self, border_color, border_width):
Sets this widget's style.
Parameters
border_color:strBorder color
border_width:intBorder width
gui =

Undocumented

_allow_delete =

Undocumented

_col_keys =

Undocumented

_col_options =

Undocumented

_col_types =

Undocumented

_on_cell_edited =

Undocumented

_on_row_deleted =

Undocumented

_on_selection_changed =

Undocumented

_row_count_minimum =

Undocumented

_row_prefix =

Undocumented