After inserting a row in a QAbstractTableModel subclass, the QTableView will not display the new record!
-
wrote on 6 Aug 2024, 21:34 last edited by
The QAbstractTableModel subclass holds a vector of rows as its data source. When I insert a new row to the vector by inserting into the vector, like this:
auto tmp = this->rows[row]; this->rows.insert(this->rows.begin() + row, tmp);
the QTableView does not display one more row!!
I tried emitting the DataChanged() signal but no success...
-
wrote on 6 Aug 2024, 22:27 last edited by jeremy_k 8 Jul 2024, 21:05
See QAbstractItemModel - Subclassing. To add a row to an existing model, QAbstractItemModel::beginInsertRows() and endInsertRows() must be called. dataChanged() is used to announce changes to existing cells.
1/2