The CustomTableWidget class is a subclass of QTableWidget that provides additional functionality and customization for table widgets.
More...
#include <customtablewidget.h>
|
void | keyPress (QKeyEvent *event) |
| Signal emitted when a key press event occurs in the table.
|
|
void | cannotDeleteRow () |
| Signal emitted when row deletion is not allowed.
|
|
|
| CustomTableWidget (QWidget *parent=nullptr) |
| Constructs a CustomTableWidget object.
|
|
bool | hasEmptyCell (const QList< int > &exceptionColumns=QList< int >()) |
| Checks if the table has any empty cells.
|
|
bool | isRowEmpty (int row, const QList< int > &exceptionColumns=QList< int >()) |
| Checks if a row is empty.
|
|
bool | isTableIncomplete (const QList< int > &exceptionColumns=QList< int >()) |
| Checks if the table is incomplete, i.e., if it does not have at least one complete row of data.
|
|
void | setCheckboxDelegateForColumns (int row, const QList< int > &columns) |
| Sets a checkbox delegate for the specified columns in a row.
|
|
void | setNumericDelegateForColumns (int row, const QList< int > &columns) |
| Sets a numeric delegate for the specified columns in a row.
|
|
void | setupTable () |
| Performs initial setup for the table.
|
|
int | generateUniqueID () |
| Generates a unique ID.
|
|
|
void | keyPressEvent (QKeyEvent *event) override |
| Overridden keyPressEvent() method to handle key press events in the table.
|
|
void | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
| Overridden setData() method for custom handling of data changes in the table.
|
|
The CustomTableWidget class is a subclass of QTableWidget that provides additional functionality and customization for table widgets.
◆ CustomTableWidget()
CustomTableWidget::CustomTableWidget |
( |
QWidget * |
parent = nullptr | ) |
|
◆ cannotDeleteRow
void CustomTableWidget::cannotDeleteRow |
( |
| ) |
|
|
signal |
Signal emitted when row deletion is not allowed.
This signal indicates that a row cannot be deleted.
◆ generateUniqueID()
int CustomTableWidget::generateUniqueID |
( |
| ) |
|
Generates a unique ID.
This method can be used to generate unique identifiers for table entries.
- Returns
- The generated unique ID.
◆ hasEmptyCell()
bool CustomTableWidget::hasEmptyCell |
( |
const QList< int > & |
exceptionColumns = QList<int>() | ) |
|
Checks if the table has any empty cells.
- Parameters
-
exceptionColumns | The columns to exclude from the check. |
- Returns
- True if there is at least one empty cell, false otherwise.
◆ isRowEmpty()
bool CustomTableWidget::isRowEmpty |
( |
int |
row, |
|
|
const QList< int > & |
exceptionColumns = QList<int>() |
|
) |
| |
Checks if a row is empty.
- Parameters
-
row | The row index. |
exceptionColumns | The columns to exclude from the check. |
- Returns
- True if the row is empty, false otherwise.
◆ isTableIncomplete()
bool CustomTableWidget::isTableIncomplete |
( |
const QList< int > & |
exceptionColumns = QList<int>() | ) |
|
Checks if the table is incomplete, i.e., if it does not have at least one complete row of data.
A row is considered complete if all cells in the row have non-empty data.
- Parameters
-
exceptionColumns | (optional) A list of column indices to exclude from the completeness check. Any rows that only have empty cells in the specified columns will still be considered incomplete. Defaults to an empty list, which means all columns will be considered for completeness. |
- Returns
- true if the table is incomplete, i.e., it does not have at least one complete row of data. false if the table has at least one complete row.
◆ keyPress
void CustomTableWidget::keyPress |
( |
QKeyEvent * |
event | ) |
|
|
signal |
Signal emitted when a key press event occurs in the table.
- Parameters
-
◆ keyPressEvent()
void CustomTableWidget::keyPressEvent |
( |
QKeyEvent * |
event | ) |
|
|
overrideprotected |
Overridden keyPressEvent() method to handle key press events in the table.
- Parameters
-
◆ setCheckboxDelegateForColumns()
void CustomTableWidget::setCheckboxDelegateForColumns |
( |
int |
row, |
|
|
const QList< int > & |
columns |
|
) |
| |
Sets a checkbox delegate for the specified columns in a row.
- Parameters
-
row | The row index. |
columns | The columns to set the checkbox delegate for. |
◆ setData()
void CustomTableWidget::setData |
( |
const QModelIndex & |
index, |
|
|
const QVariant & |
value, |
|
|
int |
role = Qt::EditRole |
|
) |
| |
|
protected |
Overridden setData() method for custom handling of data changes in the table.
- Parameters
-
index | The model index of the item. |
value | The new value for the item. |
role | The role for the item. |
◆ setNumericDelegateForColumns()
void CustomTableWidget::setNumericDelegateForColumns |
( |
int |
row, |
|
|
const QList< int > & |
columns |
|
) |
| |
Sets a numeric delegate for the specified columns in a row.
- Parameters
-
row | The row index. |
columns | The columns to set the numeric delegate for. |
◆ setupTable()
void CustomTableWidget::setupTable |
( |
| ) |
|
Performs initial setup for the table.
This includes setting up default properties and signals/slots connections.