The documentation for QSqlQuery::size() states:

"Returns the size of the result (number of rows returned), or -1 if the size cannot be determined or if the database does not support reporting information about query sizes."

I have actually encountered this issue with sqlite3 in the past: QSqlDriver::hasFeature(QSqlDriver::QuerySize) returns false. This leads to nasty issues as the database query may work perfectly, but the size() function returns -1 nevertheless.