Class: QgsTableEditorWidget¶
- class qgis.gui.QgsTableEditorWidget(parent: QWidget = None)¶
Bases:
PyQt5.QtWidgets.QTableWidget
Constructor for
QgsTableEditorWidget
with the specifiedparent
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.Methods
Clears the contents of the currently selected cells.
columnCountChanged
columnMoved
columnResized
Returns a list of the columns associated with the current table selected cells.
currentChanged
dataChanged
Deletes all columns associated with the current selected cells.
Deletes all rows associated with the current selected cells.
Expands out the selection to include whole columns associated with the current selected cells.
Expands out the selection to include whole rows associated with the current selected cells.
Returns
True
if the current selection has a mix of numeric formats.Inserts new columns after the current selection.
Inserts new columns before the current selection.
Inserts new rows above the current selection.
Inserts new rows below the current selection.
Returns
True
if any header cells are selected.- param event
rowCountChanged
rowMoved
rowResized
rowsAboutToBeRemoved
Returns a list of the rows associated with the current table selected cells.
rowsInserted
scrollContentsBy
scrollDirtyRegion
Returns the background color for the currently selected cells.
Returns the
QgsProperty
used for the contents of the currently selected cells.selectionChanged
Returns the width (in millimeters) of the columns associated with the current selection, or 0 if an automatic column width is desired.
Returns the foreground color for the currently selected cells.
Returns the horizontal alignment for the currently selected cells.
Returns the numeric format used for the currently selected cells, or
None
if the selection has no numeric format set.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.
Returns the text format for the currently selected cells.
Returns the horizontal alignment for the currently selected cells.
Sets whether the table includes a header row.
Sets the background color for the currently selected cells.
Sets the cell contents
QgsProperty
for the currently selected cells.Sets the column
width
(in millimeters) for the currently selected columns, or 0 for automatic column width.Sets the foreground color for the currently selected cells.
Sets the horizontal alignment for the currently selected cells.
Sets the numeric
format
to use for the currently selected cells.Sets the row
height
(in millimeters) for the currently selected rows, or 0 for automatic row height.Sets the text
format
for the selected cells.Sets the vertical alignment for the currently selected cells.
Sets the configured column
width
for the specifiedcolumn
.Sets the
contents
to show in the editor widget.Sets the table
headers
.Sets the configured row
height
for the specifiedrow
.Returns the configured column width for the specified
column
, or 0 if an automatic width should be used for the column.Returns the current contents of the editor widget table.
Returns the table header values.
Returns the configured row height for the specified
row
, or 0 if an automatic height should be used for the row.Signals
Emitted whenever the active (or selected) cell changes in the widget.
Emitted whenever the table contents are changed.
- actionEvent(self, QActionEvent)¶
- activeCellChanged¶
Emitted whenever the active (or selected) cell changes in the widget. [signal]
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- clearSelectedCells(self)¶
Clears the contents of the currently selected cells.
- closeEditor(self, QWidget, QAbstractItemDelegate.EndEditHint)¶
- closeEvent(self, QCloseEvent)¶
- QgsTableEditorWidget.columnCountChanged(self, int, int)
- QgsTableEditorWidget.columnMoved(self, int, int, int)
- QgsTableEditorWidget.columnResized(self, int, int, int)
- columnsAssociatedWithSelection(self) → List[int]¶
Returns a list of the columns associated with the current table selected cells.
See also
- Return type
List[int]
- commitData(self, QWidget)¶
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- QgsTableEditorWidget.currentChanged(self, QModelIndex, QModelIndex)
- customEvent(self, QEvent)¶
- QgsTableEditorWidget.dataChanged(self, QModelIndex, QModelIndex, roles: Iterable[int] = [])
- deleteColumns(self)¶
Deletes all columns associated with the current selected cells.
See also
- deleteRows(self)¶
Deletes all rows associated with the current selected cells.
See also
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- dirtyRegionOffset(self) → QPoint¶
- disconnectNotify(self, QMetaMethod)¶
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- drawFrame(self, QPainter)¶
- dropEvent(self, QDropEvent)¶
- dropIndicatorPosition(self) → QAbstractItemView.DropIndicatorPosition¶
- dropMimeData(self, int, int, QMimeData, Qt.DropAction) → bool¶
- edit(self, QModelIndex)¶
- edit(self, QModelIndex, QAbstractItemView.EditTrigger, QEvent) → bool
- editorDestroyed(self, QObject)¶
- enterEvent(self, QEvent)¶
- event(self, QEvent) → bool¶
- eventFilter(self, QObject, QEvent) → bool¶
- executeDelayedItemsLayout(self)¶
- expandColumnSelection(self)¶
Expands out the selection to include whole columns associated with the current selected cells.
See also
- expandRowSelection(self)¶
Expands out the selection to include whole rows associated with the current selected cells.
See also
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) → bool¶
- focusNextPrevChild(self, bool) → bool¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) → bool¶
- hasMixedSelectionNumericFormat(self) → bool¶
Returns
True
if the current selection has a mix of numeric formats.See also
- Return type
bool
- hideEvent(self, QHideEvent)¶
- horizontalOffset(self) → int¶
- horizontalScrollbarAction(self, int)¶
- horizontalScrollbarValueChanged(self, int)¶
- indexFromItem(self, QTableWidgetItem) → QModelIndex¶
- initPainter(self, QPainter)¶
- initStyleOption(self, QStyleOptionFrame)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- insertColumnsAfter(self)¶
Inserts new columns after the current selection.
See also
- insertColumnsBefore(self)¶
Inserts new columns before the current selection.
See also
- insertRowsAbove(self)¶
Inserts new rows above the current selection.
See also
- insertRowsBelow(self)¶
Inserts new rows below the current selection.
See also
- isHeaderCellSelected(self) → bool¶
Returns
True
if any header cells are selected.- Return type
bool
- isIndexHidden(self, QModelIndex) → bool¶
- isSignalConnected(self, QMetaMethod) → bool¶
- itemFromIndex(self, QModelIndex) → QTableWidgetItem¶
- items(self, QMimeData) → List[QTableWidgetItem]¶
- keyPressEvent(self, event: QKeyEvent)¶
- Parameters
event (QKeyEvent) –
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- metric(self, QPaintDevice.PaintDeviceMetric) → int¶
- mimeData(self, Iterable[QTableWidgetItem]) → QMimeData¶
- mimeTypes(self) → List[str]¶
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveCursor(self, QAbstractItemView.CursorAction, Union[Qt.KeyboardModifiers, Qt.KeyboardModifier]) → QModelIndex¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], sip.voidptr) → Tuple[bool, int]¶
- paintEvent(self, QPaintEvent)¶
- receivers(self, PYQT_SIGNAL) → int¶
- resizeEvent(self, QResizeEvent)¶
- QgsTableEditorWidget.rowCountChanged(self, int, int)
- QgsTableEditorWidget.rowMoved(self, int, int, int)
- QgsTableEditorWidget.rowResized(self, int, int, int)
- QgsTableEditorWidget.rowsAboutToBeRemoved(self, QModelIndex, int, int)
- rowsAssociatedWithSelection(self) → List[int]¶
Returns a list of the rows associated with the current table selected cells.
See also
- Return type
List[int]
- QgsTableEditorWidget.rowsInserted(self, QModelIndex, int, int)
- scheduleDelayedItemsLayout(self)¶
- QgsTableEditorWidget.scrollContentsBy(self, int, int)
- QgsTableEditorWidget.scrollDirtyRegion(self, int, int)
- selectedIndexes(self) → List[QModelIndex]¶
- 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.
See also
See also
- Return type
QColor
- selectionCellProperty(self) → QgsProperty¶
Returns the
QgsProperty
used for the contents of the currently selected cells.If the returned value is a default constructed
QgsProperty
, then the selected cells have a mix of different properties.New in version 3.16.
- Return type
- QgsTableEditorWidget.selectionChanged(self, QItemSelection, QItemSelection)
- 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.
See also
- Return type
float
- selectionCommand(self, QModelIndex, event: QEvent = None) → QItemSelectionModel.SelectionFlags¶
- 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.
See also
See also
Deprecated since version use:
selectionTextFormat()
instead.- Return type
QColor
- selectionHorizontalAlignment(self) → Qt.Alignment¶
Returns the horizontal alignment for the currently selected cells.
If the returned value contains both horizontal and vertical alignment flags, then the selected cells have a mix of different horizontal alignments.
See also
- Return type
Qt.Alignment
- 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.See also
See also
- Return type
- 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.
See also
- Return type
float
- selectionTextFormat(self) → QgsTextFormat¶
Returns the text format for the currently selected cells.
Returns an invalid
QgsTextFormat
if the selection has mixed text format.New in version 3.16.
- Return type
- selectionVerticalAlignment(self) → Qt.Alignment¶
Returns the horizontal alignment for the currently selected cells.
If the returned value contains both horizontal and vertical alignment flags, then the selected cells have a mix of different vertical alignments.
See also
- Return type
Qt.Alignment
- sender(self) → QObject¶
- senderSignalIndex(self) → int¶
- setDirtyRegion(self, QRegion)¶
- setIncludeTableHeader(self, included: bool)¶
Sets whether the table includes a header row.
See also
includeTableHeader()
- Parameters
included (bool) –
- setSelection(self, QRect, Union[QItemSelectionModel.SelectionFlags, QItemSelectionModel.SelectionFlag])¶
- setSelectionBackgroundColor(self, color: Union[QColor, Qt.GlobalColor])¶
Sets the background color for the currently selected cells.
See also
See also
- Parameters
color (Union[QColor) –
- setSelectionCellProperty(self, property: QgsProperty)¶
Sets the cell contents
QgsProperty
for the currently selected cells.New in version 3.16.
- Parameters
property (QgsProperty) –
- setSelectionColumnWidth(self, height: float)¶
Sets the column
width
(in millimeters) for the currently selected columns, or 0 for automatic column width.See also
- Parameters
height (float) –
- setSelectionForegroundColor(self, color: Union[QColor, Qt.GlobalColor])¶
Sets the foreground color for the currently selected cells.
See also
See also
Deprecated since version Use:
setSelectionTextFormat()
instead.- Parameters
color (Union[QColor) –
- setSelectionHorizontalAlignment(self, alignment: Union[Qt.Alignment, Qt.AlignmentFlag])¶
Sets the horizontal alignment for the currently selected cells.
See also
See also
New in version 3.16.
- Parameters
alignment (Union[Qt.Alignment) –
- setSelectionNumericFormat(self, format: QgsNumericFormat)¶
Sets the numeric
format
to use for the currently selected cells.Ownership of
format
is transferred to the widget.See also
- Parameters
format (QgsNumericFormat) –
- setSelectionRowHeight(self, height: float)¶
Sets the row
height
(in millimeters) for the currently selected rows, or 0 for automatic row height.See also
- Parameters
height (float) –
- setSelectionTextFormat(self, format: QgsTextFormat)¶
Sets the text
format
for the selected cells.New in version 3.16.
- Parameters
format (QgsTextFormat) –
- setSelectionVerticalAlignment(self, alignment: Union[Qt.Alignment, Qt.AlignmentFlag])¶
Sets the vertical alignment for the currently selected cells.
See also
See also
New in version 3.16.
- Parameters
alignment (Union[Qt.Alignment) –
- setState(self, QAbstractItemView.State)¶
- setTableColumnWidth(self, column: int, width: float)¶
Sets the configured column
width
for the specifiedcolumn
. Setwidth
to 0 if an automatic width should be used for the column.This should be called after a call to
setTableContents()
.See also
- Parameters
column (int) –
width (float) –
- setTableContents(self, contents: object)¶
Sets the
contents
to show in the editor widget.See also
- Parameters
contents (object) –
- setTableHeaders(self, headers: Iterable[Any])¶
Sets the table
headers
.See also
- Parameters
headers (Iterable[Any]) –
- setTableRowHeight(self, row: int, height: float)¶
Sets the configured row
height
for the specifiedrow
. Setheight
to 0 if an automatic height should be used for the row.This should be called after a call to
setTableContents()
.See also
- Parameters
row (int) –
height (float) –
- QgsTableEditorWidget.setViewportMargins(self, int, int, int, int)
- setViewportMargins(self, QMargins) → None¶
- showEvent(self, QShowEvent)¶
- sizeHintForColumn(self, int) → int¶
- sizeHintForRow(self, int) → int¶
- startDrag(self, Union[Qt.DropActions, Qt.DropAction])¶
- state(self) → QAbstractItemView.State¶
- supportedDropActions(self) → Qt.DropActions¶
- 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.
See also
- Return type
object
- tableHeaders(self) → List[Any]¶
Returns the table header values.
See also
- Return type
List[Any]
- 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(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- updateEditorData(self)¶
- updateEditorGeometries(self)¶
- updateGeometries(self)¶
- updateMicroFocus(self)¶
- verticalOffset(self) → int¶
- verticalScrollbarAction(self, int)¶
- verticalScrollbarValueChanged(self, int)¶
- viewOptions(self) → QStyleOptionViewItem¶
- viewportEvent(self, QEvent) → bool¶
- viewportMargins(self) → QMargins¶
- viewportSizeHint(self) → QSize¶
- visualRegionForSelection(self, QItemSelection) → QRegion¶
- wheelEvent(self, QWheelEvent)¶