Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-197

QSqlTableModel::setDataBase

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Out of scope
    • Icon: P4: Low P4: Low
    • Some future release
    • 4.2.0
    • SQL Support
    • None

      You cannot set the QSqlDatabase object that QSqlTable model uses outside of the ctor.

      I expected to see a method called:

      QSqlTableModel::setTable( const QString &tableName, const QSqlDatabase &db );

      E.g. like

      QSqlQueryModel::setQuery(const QString &qry, const QSqlDatabase &db);

      --------------------------------------------------------------------

      Suggestion from open source community how to implement this:

      qsqltablemodel.h

         public:
            void setDatabase( QSqlDatabase db );
      
      qsqltablemodel.cpp
      
      /*!
         Sets the database connection to the one given.
      */
      void QSqlTableModel::setDatabase( QSqlDatabase db )
         {
         Q_D(QSqlTableModel);
         d->db = db.isValid() ? db : QSqlDatabase::database();
         }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Unassigned Unassigned
            rve Anders Bakken
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes