I have a QTableView made from a MySQL query in Qt as follows:
tableView = new QTableView(this);
tableView->setModel(tableModel);
tableView->setSelectionBehavior(QAbstractItemView::SelectItems);
tableView->resizeColumnsToContents();
Where tableModel
is a QSqlTableModel*
. I found the solution here to be item->setFlags(item->flags() & ~Qt::ItemIsEditable);
, but I'm not adding the data to the table item by item. So what's the solution in this case?