title: What is the correct way of QSqlDatabase & QSqlQuery?
body: <p>I got confused with the manual , should i work like this:</p>
  
  <pre><code>{
   QSqlDatabase db = QSqlDatabase::addDatabase (...);
   QSqlQuery query (db);
   query.exec (...);
  }
  
  QSqlDatabase::removeDatabase (...);
  </code></pre>
  
  <p>As the document points out, <code>query</code> or <code>db</code> will be deconstructed automatically.
  But is that efficient ?</p>
  
  <p>Well , if i cache <code>db</code> inside a class , like the following:</p>
  
  <pre><code>class Dummy {
    Dummy() { 
      db = QSqlDatabase::addDatabase (...);
    }
    ~Dummy() {
      db.close();
    }
  
    bool run() {
      QSqlQuery query (db);
      bool retval = query.exec (...);
      blabla ...
    }
  
    private:
      QSqlDatabase db;
  };
  </code></pre>
  
  <p>Sometimes i could see warnings like: </p>
  
  <pre><code>QSqlDatabasePrivate::removeDatabase: connection 'BLABLA' is still in use, all queries will cease to work.
  </code></pre>
  
  <p>Even if i didn't call <code>run()</code>.</p>