The database has text and int fields. The last is a timestamp. I can not understand how you can display the date and time in the table based on this time stamp. Now only the timestamp value is displayed ...
QSqlQueryModel *model = new QSqlQueryModel(this); model->setQuery("SELECT text, timestamp FROM notes"); model->setHeaderData(0, Qt::Horizontal, tr("Text")); model->setHeaderData(1, Qt::Horizontal, tr("Created")); QTableView *view = new QTableView; view->setModel(model); view->resizeColumnsToContents();