Does QSqlQuery release automatically?

Viewed 29

Does QSqlQuery release automatically? Qt Version:5.12 DataBase:SQLite

  1. If a QSqlquery object goes out of scope, is it automatically released? Should I use clear() or finish() to release instead?

  2. If I wanna use an QSqlquery many times, shoule I use clear() or finish() to release it? For example:

QSqlQuery theQuery;
theQuery.exec("SELECT * From Table");
theQuery.next();

//some statements at the same scope

//Need to use clear() or finish() at there? (reuse)
theQuery.exec("SELECT * From Table2");
theQuery.next();
//Need to use clear() or finish() at there? (destruct)
return;
  1. Should I use a global(long existence) QSqlquery object or a temporary one?
0 Answers
Related