Hello !!!
I am trying to load my data base table to tableView.I have written the following piece of code.
void UserLog:n_pushButton_7_clicked()
{
login conn;
QSqlQueryModel *modal =new QSqlQueryModel;
conn.connOpen();
QSqlQuery* qry = new QSqlQuery(conn.db);
qry->prepare("select * from `posdb`.items");
if(qry->exec())
{
modal->setQuery(*qry);
ui->tableView->setModel(modal);
conn.connClose();
}
else
{
QMessageBox::critical(this,tr("error::"),qry->lastError().text());
}
qDebug() <<(modal->rowCount());
}
It is successfully loading the table.But the problem is that the table fields are emptyuser login11.jpg
I do not guess what is the wrong with my code.I am using the following version of Qt user login12.jpg
My database table is user login13.jpg
I am afraid what to do.
Help !!!
Thanks
Bookmarks