Class: QgsTableEditorDialog

A reusable window 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.

Added in version 3.12.

QgsTableEditorDialog

QgsTableEditorDialog

Class Hierarchy

Inheritance diagram of qgis.gui.QgsTableEditorDialog

Base classes

QMainWindow

QWidget

QObject

QPaintDevice

Methods

includeTableHeader

Returns True if the table includes a header row.

layer

Returns the (possibly None) layer associated with the expression editor context.

registerExpressionContextGenerator

Register an expression context generator class that will be used to retrieve an expression context for the editor when required.

setIncludeTableHeader

Sets whether the table includes a header row.

setLayer

Sets the layer to be used associated with the expression editor context.

setTableColumnWidth

Sets the configured column width for the specified column.

setTableContents

Sets the contents to show in the editor widget.

setTableContentsFromClipboard

Parses the clipboard text into contents to show in the editor widget.

setTableHeaders

Sets the table headers.

setTableRowHeight

Sets the configured row height for the specified row.

tableColumnWidth

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

tableContents

Returns the current contents of the editor widget table.

tableHeaders

Returns the table header values.

tableRowHeight

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

Signals

includeHeaderChanged

Emitted whenever the "include table header" setting is changed.

tableChanged

Emitted whenever the table contents are changed.

class qgis.gui.QgsTableEditorDialog[source]

Bases: QMainWindow

__init__(parent: QWidget | None = None)

Constructor for QgsTableEditorDialog with the specified parent widget.

Parameters:

parent (Optional[QWidget] = None)

signal includeHeaderChanged(included: bool)[source]

Emitted whenever the “include table header” setting is changed.

Parameters:

included (bool)

includeTableHeader(self) bool[source]

Returns True if the table includes a header row.

Return type:

bool

layer(self) QgsMapLayer | None[source]

Returns the (possibly None) layer associated with the expression editor context.

Added in version 3.40.

Return type:

Optional[QgsMapLayer]

registerExpressionContextGenerator(self, generator: QgsExpressionContextGenerator | None)[source]

Register an expression context generator class that will be used to retrieve an expression context for the editor when required.

Added in version 3.16.

Parameters:

generator (Optional[QgsExpressionContextGenerator])

setIncludeTableHeader(self, included: bool)[source]

Sets whether the table includes a header row.

Parameters:

included (bool)

setLayer(self, layer: QgsMapLayer | None)[source]

Sets the layer to be used associated with the expression editor context.

Added in version 3.40.

Parameters:

layer (Optional[QgsMapLayer])

setTableColumnWidth(self, column: int, width: float)[source]

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: Any)[source]

Sets the contents to show in the editor widget.

See also

tableContents()

Parameters:

contents (Any)

setTableContentsFromClipboard(self) bool[source]

Parses the clipboard text into contents to show in the editor widget.

Return type:

bool

Returns:

True if the clipboard was successfully parsed

See also

tableContents()

setTableHeaders(self, headers: Iterable[Any])[source]

Sets the table headers.

See also

tableHeaders()

Parameters:

headers (Iterable[Any])

setTableRowHeight(self, row: int, height: float)[source]

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)

signal tableChanged[source]

Emitted whenever the table contents are changed.

tableColumnWidth(self, column: int) float[source]

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) Any[source]

Returns the current contents of the editor widget table.

Return type:

Any

tableHeaders(self) List[Any][source]

Returns the table header values.

Return type:

List[Any]

tableRowHeight(self, row: int) float[source]

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