I believe your problem may be caused by db.close(); on line 52. Your query model objects are pointers that are remaining in scope with a reference to this QSqlDatabase object after it has been closed.

void QSqlDatabase::close ()
Closes the database connection, freeing any resources acquired, and invalidating any existing QSqlQuery objects that are used with the database.

This will also affect copies of this QSqlDatabase object.

See also removeDatabase().
Perhaps using a persistent database connection which remains in scope until after you delete your query models will work better. You can close your database connection in the deconstructor after deleting the queries. Unless you need connections to multiple different databases from the same thread this would also be more efficient as you won't need to constantly open and close connections as well.