From the docs:Works fine when the query is created in your "registrar_BD" method. You'll have to handle error messaging some other way if you do that though.Warning: You must load the SQL driver and open the connection before a QSqlQuery is created.
HTH
Bookmarks