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(); 

    1 answer 1

    Good day! If I understand you correctly, then QSqlQueryModel interprets the timestamp as a prime number. You can inherit your class from QSqlQueryModel and overlay the data() method in it (for details on how this is done, see the documentation) and implement it so that it returns QDateTime (for example, use the static QDateTime::fromTime_t() method QDateTime::fromTime_t() .