Qt/SQL - Get column type and name from table without record
QSqlDriver::record()
takes a table name and returns a QSqlRecord
, from which you can fetch the fields using QSqlRecord::field()
.
So, given a QSqlDatabase
db,
- fetch the driver with
db.driver()
, - fetch the list of tables with
db.tables()
, - fetch the a
QSqlRecord
for each table fromdriver->record(tableName)
, and - fetch the number of fields with
record.count()
and the name and type withrecord.field(x)