Re: QSqlQuery return result
Take a look at the docs under "Detailed Description"
Re: QSqlQuery return result
Quote:
QString result = query.result();
query.result() will return a pointer on a const QSqlResult . You statement can not work.
According to Qt doc:
Quote:
Normally, you would use QSqlQuery instead of QSqlResult, since QSqlQuery provides a generic wrapper for database-specific implementations of QSqlResult.
If you are implementing your own SQL driver (by subclassing QSqlDriver), you will need to provide your own QSqlResult subclass that implements all the pure virtual functions and other virtual functions that you need.
Retrieving records:
Quote:
Once an active query is positioned on a valid record, data can be retrieved using value(). All data is transferred from the SQL backend using QVariants.
Code:
while (query.next()) {
QString country
= query.
value(0).
toString();
doSomething(country);
}