Class: QgsTableEditorWidget

class qgis.gui.QgsTableEditorWidget(parent: QWidget = None)

Bases: PyQt5.QtWidgets.QTableWidget

Constructor for QgsTableEditorWidget with the specified parent widget.

A reusable widget for editing simple spreadsheet-style tables.

Table content is retrieved and set using the QgsTableContents class. The editor has support for table foreground and background colors, and numeric formats.

New in version 3.12.

Parameters

parent

actionEvent()
activeCellChanged

Emitted whenever the active (or selected) cell changes in the widget. [signal]

changeEvent()
childEvent()
clearSelectedCells(self)

Clears the contents of the currently selected cells.

closeEditor()
closeEvent()
columnCountChanged()
columnMoved()
columnResized()
columnsAssociatedWithSelection(self) → List[int]

Returns a list of the columns associated with the current table selected cells.

Return type

List[int]

commitData()
connectNotify()
contextMenuEvent()
create()
currentChanged()
customEvent()
dataChanged()
deleteColumns(self)

Deletes all columns associated with the current selected cells.

See also

deleteRows()

deleteRows(self)

Deletes all rows associated with the current selected cells.

See also

deleteColumns()

destroy()
dirtyRegionOffset()
disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
drawFrame()
dropEvent()
dropIndicatorPosition()
dropMimeData()
edit()
editorDestroyed()
enterEvent()
event()
eventFilter()
executeDelayedItemsLayout()
expandColumnSelection(self)

Expands out the selection to include whole columns associated with the current selected cells.

expandRowSelection(self)

Expands out the selection to include whole rows associated with the current selected cells.

focusInEvent()
focusNextChild()
focusNextPrevChild()
focusOutEvent()
focusPreviousChild()
hasMixedSelectionNumericFormat(self) → bool

Returns True if the current selection has a mix of numeric formats.

Return type

bool

hideEvent()
horizontalOffset()
horizontalScrollbarAction()
horizontalScrollbarValueChanged()
indexFromItem()
initPainter()
initStyleOption()
inputMethodEvent()
insertColumnsAfter(self)

Inserts new columns after the current selection.

insertColumnsBefore(self)

Inserts new columns before the current selection.

insertRowsAbove(self)

Inserts new rows above the current selection.

insertRowsBelow(self)

Inserts new rows below the current selection.

isIndexHidden()
isSignalConnected()
itemFromIndex()
items()
keyPressEvent(self, event: QKeyEvent)
Parameters

event (QKeyEvent) –

keyReleaseEvent()
leaveEvent()
metric()
mimeData()
mimeTypes()
mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent()
mouseReleaseEvent()
moveCursor()
moveEvent()
nativeEvent()
paintEvent()
receivers()
resizeEvent()
rowCountChanged()
rowMoved()
rowResized()
rowsAboutToBeRemoved()
rowsAssociatedWithSelection(self) → List[int]

Returns a list of the rows associated with the current table selected cells.

Return type

List[int]

rowsInserted()
scheduleDelayedItemsLayout()
scrollContentsBy()
scrollDirtyRegion()
selectedIndexes()
selectionBackgroundColor(self) → QColor

Returns the background color for the currently selected cells.

If the selected cells have a mix of different background colors then an invalid color will be returned.

Return type

QColor

selectionChanged()
selectionColumnWidth(self) → float

Returns the width (in millimeters) of the columns associated with the current selection, or 0 if an automatic column width is desired.

Return type

float

selectionCommand()
selectionForegroundColor(self) → QColor

Returns the foreground color for the currently selected cells.

If the selected cells have a mix of different foreground colors then an invalid color will be returned.

Return type

QColor

selectionNumericFormat(self) → QgsNumericFormat

Returns the numeric format used for the currently selected cells, or None if the selection has no numeric format set.

If the selected cells have a mix of different formats then None will be returned.

Return type

QgsNumericFormat

selectionRowHeight(self) → float

Returns the height (in millimeters) of the rows associated with the current selection, or 0 if an automatic row height is desired, or -1 if the selection has mixed row heights.

Return type

float

sender()
senderSignalIndex()
setDirtyRegion()
setSelection()
setSelectionBackgroundColor(self, color: Union[QColor, Qt.GlobalColor])

Sets the background color for the currently selected cells.

Parameters

color (Union[QColor) –

setSelectionColumnWidth(self, height: float)

Sets the column width (in millimeters) for the currently selected columns, or 0 for automatic column width.

Parameters

height (float) –

setSelectionForegroundColor(self, color: Union[QColor, Qt.GlobalColor])

Sets the foreground color for the currently selected cells.

Parameters

color (Union[QColor) –

setSelectionNumericFormat(self, format: QgsNumericFormat)

Sets the numeric format to use for the currently selected cells.

Ownership of format is transferred to the widget.

Parameters

format (QgsNumericFormat) –

setSelectionRowHeight(self, height: float)

Sets the row height (in millimeters) for the currently selected rows, or 0 for automatic row height.

Parameters

height (float) –

setState()
setTableColumnWidth(self, column: int, width: float)

Sets the configured column width for the specified column. Set width to 0 if an automatic width should be used for the column.

This should be called after a call to setTableContents().

Parameters
  • column (int) –

  • width (float) –

setTableContents(self, contents: object)

Sets the contents to show in the editor widget.

See also

tableContents()

Parameters

contents (object) –

setTableRowHeight(self, row: int, height: float)

Sets the configured row height for the specified row. Set height to 0 if an automatic height should be used for the row.

This should be called after a call to setTableContents().

See also

tableRowHeight()

Parameters
  • row (int) –

  • height (float) –

setViewportMargins()
sharedPainter()
showEvent()
sizeHintForColumn()
sizeHintForRow()
startDrag()
state()
supportedDropActions()
tableChanged

Emitted whenever the table contents are changed. [signal]

tableColumnWidth(self, column: int) → float

Returns the configured column width for the specified column, or 0 if an automatic width should be used for the column.

Parameters

column (int) –

Return type

float

tableContents(self) → object

Returns the current contents of the editor widget table.

Return type

object

tableRowHeight(self, row: int) → float

Returns the configured row height for the specified row, or 0 if an automatic height should be used for the row.

Parameters

row (int) –

Return type

float

tabletEvent()
timerEvent()
updateEditorData()
updateEditorGeometries()
updateGeometries()
updateMicroFocus()
verticalOffset()
verticalScrollbarAction()
verticalScrollbarValueChanged()
viewOptions()
viewportEvent()
viewportMargins()
viewportSizeHint()
visualRegionForSelection()
wheelEvent()