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

QSqlTableModel::setDataBase

    XMLWordPrintable

Details

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

    Description

      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();
         }
      

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes