QSqlQuery::prepare(), QSqlQuery::exec(), and QSqlQuery::first() all return Boolean values indicating success or failure. You don't check them, so how do you know if the query succeeded at all?