QSqlQuery 只返回带有 SELECT * FROM ... 的两列,知道为什么我没有得到所有列吗?

QSqlQuery is only returning two columns with SELECT * FROM ..., any idea why I don't get all the columns?

我有一个包含 16 列的 table。我使用 QSqlQuery class 执行 SELECT。我得到了预期的两行,但只有 16 列中的前两列。

这是查询的简化版本

QSqlQuery query(f_db);
query.prepare(QString("SELECT * FROM my_table WHERE status = 'good'");
query.exec();
query.next();
int const max(query.size());  // here max == 2 instead of 16
for(int idx(0); idx < max; ++idx)
{
    QVariant v(it->second->value(idx));
    ...v is correct for column 1 and 2...
}

知道为什么 MySQL 不会 return 所有 16 列。

根据这个 article 你得到的是行数而不是列数,query.size() 返回记录数。但是 query.record().count 返回列数