Hello to each and everyone, I'm trying to put in a tableview a checkbox which should be linked to a value in the db of SQlite, the program select first a query and insert data into the table but I want to add a column with a checkbox for each record found in the db. How can i add it to the QSqlQueryModel and Qtableview already created by QTcreator?
Thank you so much
This is my code:
void myClass::on_pushButton_clicked()
{
Widget conn;
conn.connOpen();
qry->prepare("select * from plan where username='"+username_temp+"'");
qry->exec();
model->setQuery(*qry);
ui->tableView->setModel(model);
conn.connClose();
qDebug() << (model->rowCount());
}
void myClass::on_pushButton_clicked()
{
Widget conn;
QSqlQueryModel * model = new QSqlQueryModel();
conn.connOpen();
QSqlQuery* qry = new QSqlQuery(conn.db);
qry->prepare("select * from plan where username='"+username_temp+"'");
qry->exec();
QTextStream (stdout) << qry->lastQuery();
model->setQuery(*qry);
ui->tableView->setModel(model);
conn.connClose();
qDebug() << (model->rowCount());
}
To copy to clipboard, switch view to plain text mode
Bookmarks