use this...
model->setTable(trainingname);//trainingname-name of table to be viewed
model->select();
model->setHeaderData(0, Qt::Horizontal, tr("CERTIFICATES"));
model->setHeaderData(1, Qt::Horizontal, tr("CERTIFICATE NO."));
model->setHeaderData(2, Qt::Horizontal, tr("TRAINING CENTER"));
model->setHeaderData(3, Qt::Horizontal, tr("DATE"));
model->sort(0, Qt::AscendingOrder);
view->setModel(model);
model = new QSqlTableModel(this);
model->setTable(trainingname);//trainingname-name of table to be viewed
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->select();
model->setHeaderData(0, Qt::Horizontal, tr("CERTIFICATES"));
model->setHeaderData(1, Qt::Horizontal, tr("CERTIFICATE NO."));
model->setHeaderData(2, Qt::Horizontal, tr("TRAINING CENTER"));
model->setHeaderData(3, Qt::Horizontal, tr("DATE"));
model->sort(0, Qt::AscendingOrder);
view = new QTableView;
view->setModel(model);
To copy to clipboard, switch view to plain text mode
Bookmarks