Your sample code won't compile for the reason pointed out by Lykurg. Once that is corrected the code works fine for me.

You should get into the habit of checking return values and, when they indicate errors, QSqlDatabase::lastError() or QSqlQueryModel::lastError().
QSqlTableModel::select() returns a true/false indication you are ignoring.