QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Protected Member Functions | Friends | List of all members
QgsTableEditorWidget Class Reference

A reusable widget for editing simple spreadsheet-style tables. More...

#include <qgstableeditorwidget.h>

Inheritance diagram for QgsTableEditorWidget:
Inheritance graph
[legend]

Public Slots

void clearSelectedCells ()
 Clears the contents of the currently selected cells.
 
void deleteColumns ()
 Deletes all columns associated with the current selected cells.
 
void deleteRows ()
 Deletes all rows associated with the current selected cells.
 
void expandColumnSelection ()
 Expands out the selection to include whole columns associated with the current selected cells.
 
void expandRowSelection ()
 Expands out the selection to include whole rows associated with the current selected cells.
 
void insertColumnsAfter ()
 Inserts new columns after the current selection.
 
void insertColumnsBefore ()
 Inserts new columns before the current selection.
 
void insertRowsAbove ()
 Inserts new rows above the current selection.
 
void insertRowsBelow ()
 Inserts new rows below the current selection.
 
void mergeSelectedCells ()
 Merges selected table cells.
 
void setIncludeTableHeader (bool included)
 Sets whether the table includes a header row.
 
void setSelectionBackgroundColor (const QColor &color)
 Sets the background color for the currently selected cells.
 
void setSelectionCellProperty (const QgsProperty &property)
 Sets the cell contents QgsProperty for the currently selected cells.
 
void setSelectionColumnWidth (double height)
 Sets the column width (in millimeters) for the currently selected columns, or 0 for automatic column width.
 
Q_DECL_DEPRECATED void setSelectionForegroundColor (const QColor &color)
 Sets the foreground color for the currently selected cells.
 
void setSelectionHorizontalAlignment (Qt::Alignment alignment)
 Sets the horizontal alignment for the currently selected cells.
 
void setSelectionRowHeight (double height)
 Sets the row height (in millimeters) for the currently selected rows, or 0 for automatic row height.
 
void setSelectionTextFormat (const QgsTextFormat &format)
 Sets the text format for the selected cells.
 
void setSelectionVerticalAlignment (Qt::Alignment alignment)
 Sets the vertical alignment for the currently selected cells.
 
void setTableHeaders (const QVariantList &headers)
 Sets the table headers.
 
void splitSelectedCells ()
 Splits (un-merges) selected table cells.
 

Signals

void activeCellChanged ()
 Emitted whenever the active (or selected) cell changes in the widget.
 
void tableChanged ()
 Emitted whenever the table contents are changed.
 

Public Member Functions

 QgsTableEditorWidget (QWidget *parent=nullptr)
 Constructor for QgsTableEditorWidget with the specified parent widget.
 
 ~QgsTableEditorWidget () override
 
bool canMergeSelection () const
 Returns true if a selection has been made which can be merged.
 
bool canSplitSelection () const
 Returns true if a selection has been made which can be split.
 
QList< int > columnsAssociatedWithSelection ()
 Returns a list of the columns associated with the current table selected cells.
 
bool hasMixedSelectionNumericFormat ()
 Returns true if the current selection has a mix of numeric formats.
 
bool isHeaderCellSelected () const
 Returns true if any header cells are selected.
 
QList< int > rowsAssociatedWithSelection ()
 Returns a list of the rows associated with the current table selected cells.
 
QColor selectionBackgroundColor ()
 Returns the background color for the currently selected cells.
 
QgsProperty selectionCellProperty ()
 Returns the QgsProperty used for the contents of the currently selected cells.
 
double selectionColumnWidth ()
 Returns the width (in millimeters) of the columns associated with the current selection, or 0 if an automatic column width is desired.
 
Q_DECL_DEPRECATED QColor selectionForegroundColor ()
 Returns the foreground color for the currently selected cells.
 
Qt::Alignment selectionHorizontalAlignment ()
 Returns the horizontal alignment for the currently selected cells.
 
QgsNumericFormatselectionNumericFormat ()
 Returns the numeric format used for the currently selected cells, or nullptr if the selection has no numeric format set.
 
double selectionRowHeight ()
 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.
 
QgsTextFormat selectionTextFormat ()
 Returns the text format for the currently selected cells.
 
Qt::Alignment selectionVerticalAlignment ()
 Returns the horizontal alignment for the currently selected cells.
 
void setSelectionNumericFormat (QgsNumericFormat *format)
 Sets the numeric format to use for the currently selected cells.
 
void setTableColumnWidth (int column, double width)
 Sets the configured column width for the specified column.
 
void setTableContents (const QgsTableContents &contents)
 Sets the contents to show in the editor widget.
 
void setTableRowHeight (int row, double height)
 Sets the configured row height for the specified row.
 
double tableColumnWidth (int column)
 Returns the configured column width for the specified column, or 0 if an automatic width should be used for the column.
 
QgsTableContents tableContents () const
 Returns the current contents of the editor widget table.
 
QVariantList tableHeaders () const
 Returns the table header values.
 
double tableRowHeight (int row)
 Returns the configured row height for the specified row, or 0 if an automatic height should be used for the row.
 

Protected Member Functions

void keyPressEvent (QKeyEvent *event) override
 

Friends

class QgsTableEditorDelegate
 

Detailed Description

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.

Since
QGIS 3.12

Definition at line 111 of file qgstableeditorwidget.h.

Constructor & Destructor Documentation

◆ QgsTableEditorWidget()

QgsTableEditorWidget::QgsTableEditorWidget ( QWidget *  parent = nullptr)

Constructor for QgsTableEditorWidget with the specified parent widget.

Definition at line 27 of file qgstableeditorwidget.cpp.

◆ ~QgsTableEditorWidget()

QgsTableEditorWidget::~QgsTableEditorWidget ( )
override

Definition at line 161 of file qgstableeditorwidget.cpp.

Member Function Documentation

◆ activeCellChanged

void QgsTableEditorWidget::activeCellChanged ( )
signal

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

◆ canMergeSelection()

bool QgsTableEditorWidget::canMergeSelection ( ) const

Returns true if a selection has been made which can be merged.

Since
QGIS 3.40

Definition at line 870 of file qgstableeditorwidget.cpp.

◆ canSplitSelection()

bool QgsTableEditorWidget::canSplitSelection ( ) const

Returns true if a selection has been made which can be split.

Since
QGIS 3.40

Definition at line 877 of file qgstableeditorwidget.cpp.

◆ clearSelectedCells

void QgsTableEditorWidget::clearSelectedCells ( )
slot

Clears the contents of the currently selected cells.

Definition at line 1024 of file qgstableeditorwidget.cpp.

◆ columnsAssociatedWithSelection()

QList< int > QgsTableEditorWidget::columnsAssociatedWithSelection ( )

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

See also
rowsAssociatedWithSelection()

Definition at line 836 of file qgstableeditorwidget.cpp.

◆ deleteColumns

void QgsTableEditorWidget::deleteColumns ( )
slot

Deletes all columns associated with the current selected cells.

See also
deleteRows()

Definition at line 989 of file qgstableeditorwidget.cpp.

◆ deleteRows

void QgsTableEditorWidget::deleteRows ( )
slot

Deletes all rows associated with the current selected cells.

See also
deleteColumns()

Definition at line 972 of file qgstableeditorwidget.cpp.

◆ expandColumnSelection

void QgsTableEditorWidget::expandColumnSelection ( )
slot

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

See also
expandRowSelection()

Definition at line 1015 of file qgstableeditorwidget.cpp.

◆ expandRowSelection

void QgsTableEditorWidget::expandRowSelection ( )
slot

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

See also
expandColumnSelection()

Definition at line 1006 of file qgstableeditorwidget.cpp.

◆ hasMixedSelectionNumericFormat()

bool QgsTableEditorWidget::hasMixedSelectionNumericFormat ( )

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

See also
selectionNumericFormat()

Definition at line 560 of file qgstableeditorwidget.cpp.

◆ insertColumnsAfter

void QgsTableEditorWidget::insertColumnsAfter ( )
slot

Inserts new columns after the current selection.

See also
insertColumnsBefore()

Definition at line 950 of file qgstableeditorwidget.cpp.

◆ insertColumnsBefore

void QgsTableEditorWidget::insertColumnsBefore ( )
slot

Inserts new columns before the current selection.

See also
insertColumnsAfter()

Definition at line 928 of file qgstableeditorwidget.cpp.

◆ insertRowsAbove

void QgsTableEditorWidget::insertRowsAbove ( )
slot

Inserts new rows above the current selection.

See also
insertRowsBelow()

Definition at line 906 of file qgstableeditorwidget.cpp.

◆ insertRowsBelow

void QgsTableEditorWidget::insertRowsBelow ( )
slot

Inserts new rows below the current selection.

See also
insertRowsAbove()

Definition at line 884 of file qgstableeditorwidget.cpp.

◆ isHeaderCellSelected()

bool QgsTableEditorWidget::isHeaderCellSelected ( ) const

Returns true if any header cells are selected.

Definition at line 862 of file qgstableeditorwidget.cpp.

◆ keyPressEvent()

void QgsTableEditorWidget::keyPressEvent ( QKeyEvent *  event)
overrideprotected

Definition at line 346 of file qgstableeditorwidget.cpp.

◆ mergeSelectedCells

void QgsTableEditorWidget::mergeSelectedCells ( )
slot

Merges selected table cells.

See also
splitSelectedCells()
Since
QGIS 3.40

Definition at line 1359 of file qgstableeditorwidget.cpp.

◆ rowsAssociatedWithSelection()

QList< int > QgsTableEditorWidget::rowsAssociatedWithSelection ( )

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

See also
columnsAssociatedWithSelection()

Definition at line 831 of file qgstableeditorwidget.cpp.

◆ selectionBackgroundColor()

QColor QgsTableEditorWidget::selectionBackgroundColor ( )

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
setSelectionBackgroundColor()
selectionForegroundColor()

Definition at line 596 of file qgstableeditorwidget.cpp.

◆ selectionCellProperty()

QgsProperty QgsTableEditorWidget::selectionCellProperty ( )

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.

Since
QGIS 3.16

Definition at line 665 of file qgstableeditorwidget.cpp.

◆ selectionColumnWidth()

double QgsTableEditorWidget::selectionColumnWidth ( )

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

See also
setSelectionColumnWidth()

Definition at line 731 of file qgstableeditorwidget.cpp.

◆ selectionForegroundColor()

QColor QgsTableEditorWidget::selectionForegroundColor ( )

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
setSelectionForegroundColor()
selectionBackgroundColor()
Deprecated:
QGIS 3.40. Use selectionTextFormat() instead.

Definition at line 590 of file qgstableeditorwidget.cpp.

◆ selectionHorizontalAlignment()

Qt::Alignment QgsTableEditorWidget::selectionHorizontalAlignment ( )

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
selectionVerticalAlignment()

Definition at line 619 of file qgstableeditorwidget.cpp.

◆ selectionNumericFormat()

QgsNumericFormat * QgsTableEditorWidget::selectionNumericFormat ( )

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

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

See also
setSelectionNumericFormat()
hasMixedSelectionNumericFormat()

Definition at line 530 of file qgstableeditorwidget.cpp.

◆ selectionRowHeight()

double QgsTableEditorWidget::selectionRowHeight ( )

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
setSelectionRowHeight()

Definition at line 712 of file qgstableeditorwidget.cpp.

◆ selectionTextFormat()

QgsTextFormat QgsTableEditorWidget::selectionTextFormat ( )

Returns the text format for the currently selected cells.

Returns an invalid QgsTextFormat if the selection has mixed text format.

Since
QGIS 3.16

Definition at line 688 of file qgstableeditorwidget.cpp.

◆ selectionVerticalAlignment()

Qt::Alignment QgsTableEditorWidget::selectionVerticalAlignment ( )

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
selectionVerticalAlignment()

Definition at line 642 of file qgstableeditorwidget.cpp.

◆ setIncludeTableHeader

void QgsTableEditorWidget::setIncludeTableHeader ( bool  included)
slot

Sets whether the table includes a header row.

Definition at line 1321 of file qgstableeditorwidget.cpp.

◆ setSelectionBackgroundColor

void QgsTableEditorWidget::setSelectionBackgroundColor ( const QColor &  color)
slot

Sets the background color for the currently selected cells.

See also
selectionBackgroundColor()
setSelectionForegroundColor()

Definition at line 1080 of file qgstableeditorwidget.cpp.

◆ setSelectionCellProperty

void QgsTableEditorWidget::setSelectionCellProperty ( const QgsProperty property)
slot

Sets the cell contents QgsProperty for the currently selected cells.

Since
QGIS 3.16

Definition at line 1175 of file qgstableeditorwidget.cpp.

◆ setSelectionColumnWidth

void QgsTableEditorWidget::setSelectionColumnWidth ( double  height)
slot

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

See also
setSelectionRowHeight()

Definition at line 1290 of file qgstableeditorwidget.cpp.

◆ setSelectionForegroundColor

void QgsTableEditorWidget::setSelectionForegroundColor ( const QColor &  color)
slot

Sets the foreground color for the currently selected cells.

See also
selectionForegroundColor()
setSelectionBackgroundColor()
Deprecated:
QGIS 3.40. Use setSelectionTextFormat() instead.

Definition at line 1043 of file qgstableeditorwidget.cpp.

◆ setSelectionHorizontalAlignment

void QgsTableEditorWidget::setSelectionHorizontalAlignment ( Qt::Alignment  alignment)
slot

Sets the horizontal alignment for the currently selected cells.

See also
selectionHorizontalAlignment()
setSelectionVerticalAlignment()
Since
QGIS 3.16

Definition at line 1113 of file qgstableeditorwidget.cpp.

◆ setSelectionNumericFormat()

void QgsTableEditorWidget::setSelectionNumericFormat ( QgsNumericFormat format)

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

Ownership of format is transferred to the widget.

See also
selectionNumericFormat()

Definition at line 488 of file qgstableeditorwidget.cpp.

◆ setSelectionRowHeight

void QgsTableEditorWidget::setSelectionRowHeight ( double  height)
slot

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

See also
setSelectionColumnWidth()

Definition at line 1256 of file qgstableeditorwidget.cpp.

◆ setSelectionTextFormat

void QgsTableEditorWidget::setSelectionTextFormat ( const QgsTextFormat format)
slot

Sets the text format for the selected cells.

Since
QGIS 3.16

Definition at line 1226 of file qgstableeditorwidget.cpp.

◆ setSelectionVerticalAlignment

void QgsTableEditorWidget::setSelectionVerticalAlignment ( Qt::Alignment  alignment)
slot

Sets the vertical alignment for the currently selected cells.

See also
selectionVerticalAlignment()
setSelectionHorizontalAlignment()
Since
QGIS 3.16

Definition at line 1144 of file qgstableeditorwidget.cpp.

◆ setTableColumnWidth()

void QgsTableEditorWidget::setTableColumnWidth ( int  column,
double  width 
)

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().

See also
tableColumnWidth()

Definition at line 804 of file qgstableeditorwidget.cpp.

◆ setTableContents()

void QgsTableEditorWidget::setTableContents ( const QgsTableContents contents)

Sets the contents to show in the editor widget.

See also
tableContents()

Definition at line 374 of file qgstableeditorwidget.cpp.

◆ setTableHeaders

void QgsTableEditorWidget::setTableHeaders ( const QVariantList &  headers)
slot

Sets the table headers.

See also
tableHeaders()

Definition at line 1335 of file qgstableeditorwidget.cpp.

◆ setTableRowHeight()

void QgsTableEditorWidget::setTableRowHeight ( int  row,
double  height 
)

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()

Definition at line 772 of file qgstableeditorwidget.cpp.

◆ splitSelectedCells

void QgsTableEditorWidget::splitSelectedCells ( )
slot

Splits (un-merges) selected table cells.

See also
mergeSelectedCells()
Since
QGIS 3.40

Definition at line 1387 of file qgstableeditorwidget.cpp.

◆ tableChanged

void QgsTableEditorWidget::tableChanged ( )
signal

Emitted whenever the table contents are changed.

◆ tableColumnWidth()

double QgsTableEditorWidget::tableColumnWidth ( int  column)

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

Definition at line 761 of file qgstableeditorwidget.cpp.

◆ tableContents()

QgsTableContents QgsTableEditorWidget::tableContents ( ) const

Returns the current contents of the editor widget table.

See also
setTableContents()

Definition at line 435 of file qgstableeditorwidget.cpp.

◆ tableHeaders()

QVariantList QgsTableEditorWidget::tableHeaders ( ) const

Returns the table header values.

See also
setTableHeaders()

Definition at line 841 of file qgstableeditorwidget.cpp.

◆ tableRowHeight()

double QgsTableEditorWidget::tableRowHeight ( int  row)

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

Definition at line 750 of file qgstableeditorwidget.cpp.

Friends And Related Symbol Documentation

◆ QgsTableEditorDelegate

friend class QgsTableEditorDelegate
friend

Definition at line 522 of file qgstableeditorwidget.h.


The documentation for this class was generated from the following files: