How to register adding row event to QTableWidget
-
Hi guys,
I have multiple QTableWidget in my desktop application,
Currently, i assign them to use same custom context menu for adding, clone, remove row(s).
But i stuck in case: each table have different condition check when add new row.For example: Column 1 in table A is text format, column 1 in table B is checkbox format (im using setCellWidget to assign checkbox), column 1 in table C is combobox format => So if in add new row menu action, just use table->insertRow(table->rowCount()) is not enough, all cell in new row have default text field.
So, i wonder is there anyway to register adding row event on QTableWidget to create different cell format for each table?
-
My current workaround is set table not editable,
Then, implement cell double click slot.
In cell double click slot, detect which cell is clicking at, set correspond cell widget and then programmatically edit that cell like below
QModelIndex index = this->ui->tableA->model()->index(row, column); this->ui->tableA->setCurrentIndex(index); this->ui->tableA->edit(index);