M
M
Mercury132016-01-15 16:46:36
Database
Mercury13, 2016-01-15 16:46:36

Does QSqlQuery hold a smart DB pointer?

There are three questions.
1. Is QSqlDatabase a smart pointer? What will happen from such a code?

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
// ну, в общем, откроем его…
QSqlDatabase dbCopy = db;

2. Same with QSqlQuery.
3. Does QSqlQuery hold a smart pointer to the database? Does such code work?
QSqlQuery getQuery() {
  QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
  // в общем, откроем…
  return QSqlQuery("SELECT * FROM table", db);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2016-01-15
@Mercury13

Finally figured it out.
1. Yes.
2. Yes.
3. Yes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question