QSqlQueryModel 这个就可以
eg:
QSqlQueryModel *model = new QSqlQueryModel;
model->setQuery(“select * from xxx”);
model->setHeaderData(0, Qt::Horizontal, tr(“id”));
model->setHeaderData(1, Qt::Horizontal, tr(“name”));
QTableView *view = new QTableView;
view->setModel(model);
view->show();
不明白再问