Important: Please read the Qt Code of Conduct -

[SOLVED] How to display an SQLite table in Qt without the ability to change its content ?

  • Hello,

    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.

    @void myFunction::on_pushButton_clicked()
    homepage conn;
    QSqlQueryModel *model = new QSqlQueryModel();

    QSqlQuery *qry = new QSqlQuery(conn.mydb);
    qry->prepare("SELECT * from table");
    qDebug() <<(model->rowCount());



  • Lifetime Qt Champion


    Call setEditTriggers with QAbstractItemView::NoEditTriggers on your view and it will be read-only.

  • SGaist thank you very much it worked .

  • Lifetime Qt Champion

    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 :)

Log in to reply