query.result() will return a pointer on a const QSqlResult . You statement can not work.QString result = query.result();
According to Qt doc:
Retrieving records: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.
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.Qt Code:
while (query.next()) { doSomething(country); }To copy to clipboard, switch view to plain text mode
Bookmarks