[SOLVED] How to display an SQLite table in Qt without the ability to change its content ?
I wrote the following code to display an SQlite table and the table appears after execution .
My problem is that I don't want to make changes to my table which is not the case here as after execution I can make modifications to the existing table.
QSqlQueryModel *model = new QSqlQueryModel();
conn.connOpen(); QSqlQuery *qry = new QSqlQuery(conn.mydb); qry->prepare("SELECT * from table"); qry->exec(); model->setQuery(*qry); ui->tableView->setModel(model); conn.connClose(); qDebug() <<(model->rowCount());
Call setEditTriggers with QAbstractItemView::NoEditTriggers on your view and it will be read-only.
SGaist thank you very much it worked .
You're welcome !
Since you have your widget working correctly now, please update the thread tittle prepending [solved] so other forum users may know a solution has been found :)