Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2394

QSqlQueryModel.setQuery( QSqlQuery() ) Produces Deprecation Warning

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.6.0
    • 6.5.1.1
    • PySide
    • None
    • Python 3.11.4
    • Windows
    • 7ba2cb99a (dev), c06f7743b (dev), f693a1174 (6.5), f0bc9c6f4 (6.5), b8c5e37cb (dev)

    Description

      I'm not sure that 'Bug' is the most fitting issue type. I was advised to submit per this qt forum post: https://forum.qt.io/topic/146598/deprecationwarning-qsqlquerymodel-setquery

      I am trying to set a QSqlQueryModel to a QSqlQuery object. I'm using a query object rather than a string because I need the query to be parameterized, I need to prepare and bind values to the query. Here is example code:
       

          def requery(self, parent_id):
              q = QSqlQuery()
              q.prepare("""
                  SELECT id, some_field, parent_id
                  FROM child_table
                  WHERE parent_id=?
              """)
              q.addBindValue(parent_id)
              q.exec()
              self._model.setQuery(q)
      

      Doing so produces the following warning:
      DeprecationWarning: Function: 'QSqlQueryModel.setQuery(const QSqlQuery & query)' is marked as deprecated, please check the documentation for more information.

      Attachments

        1. pyside2394_cpp.zip
          1 kB
        2. pyside2394.py
          0.9 kB

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              bamboozledbaboon Kyle D
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: