#include <QDateTime>#include <QSqlQuery>#include <QTableView>#include <QApplication>#include <QSqlDatabase>#include <QSqlQueryModel>class QueryModel : public QSqlQueryModel {public: QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const { return (role == Qt::DisplayRole) ? QDateTime::fromTime_t(QSqlQueryModel::data(index, role).toUInt()).toString() : QSqlQueryModel::data(index, role) ; }};int main(int argc, char *argv[]) { QApplication a(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("test.db"); db.open(); if (!db.tables().contains("test")) db.exec("CREATE TABLE test (time integer)"); db.exec("INSERT INTO test VALUES(1234567890)"); QueryModel m; m.setQuery("SELECT time FROM test"); QTableView v; v.setModel(&m); v.show(); return a.exec();}