unable to update QTableView cell text
Unsolved
General and Desktop
-
I am trying to edit text in QTableView cell (update text base on another table) but I am unable to do any changes. Below is my code but it does not work.
QTime time = ui->tv_timeSlot->model()->data(ui->tv_timeSlot->model()->index(index.row(),index.column())).toTime(); QString timeStr = time.toString("hh:mm:ss"); ui->tv_timeCard->model()->setData(ui->tv_timeCard->model()->index(1,1),timeStr,Qt::EditRole);
I did find out that there are some people override the flags function with
Qt::ItemFlags MyTableModel::flags (const QModelIndex &index) const { return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; }
I would prefer not to override the function because I had no basic on this. But if that is the only way, please guide me. Thanks in advance
-
-
@iradarann said in unable to update QTableView cell text:
It return false. I am wondering why it unable to update and return false.
You can step into it with the debugger to find out
How can i know if i am using QStandardItemModel or MyTableModel? Or is there any way to set it?
This is set when you call
QTableView::setModel