Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. DeprecationWarning QSqlQueryModel.setQuery
QtWS25 Last Chance

DeprecationWarning QSqlQueryModel.setQuery

Scheduled Pinned Locked Moved Unsolved Qt for Python
qt for pythonpythonpyside
10 Posts 2 Posters 958 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BamboozledBaboon
    wrote on last edited by BamboozledBaboon
    #1

    Re: How to resolve this warning

    I would like to be able to apply a parameterized query to QSqlQueryModel. However it looks like model.setQuery wants a string, not a query object. What's the best way to approach this?

    I'm getting the following warning:

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

    Here's the test code:

        def requery(self, customer_id):
            q = QSqlQuery()
            q.prepare("""
                SELECT job_id, job_name, customer_id
                FROM job
                WHERE customer_id=?
            """)
            q.addBindValue(customer_id)
            q.exec()
            self._model.setQuery(q)
    

    I understand from the referenced post above that this could cause memory leaks which is why it's marked for deprecation...

    SGaistS 1 Reply Last reply
    0
    • B BamboozledBaboon

      Re: How to resolve this warning

      I would like to be able to apply a parameterized query to QSqlQueryModel. However it looks like model.setQuery wants a string, not a query object. What's the best way to approach this?

      I'm getting the following warning:

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

      Here's the test code:

          def requery(self, customer_id):
              q = QSqlQuery()
              q.prepare("""
                  SELECT job_id, job_name, customer_id
                  FROM job
                  WHERE customer_id=?
              """)
              q.addBindValue(customer_id)
              q.exec()
              self._model.setQuery(q)
      

      I understand from the referenced post above that this could cause memory leaks which is why it's marked for deprecation...

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Based on the documentation, I would say that it's rather at the binding level that it should be fixed. You can still use QSqlQuery with QSqlQueryModel.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Based on the documentation, I would say that it's rather at the binding level that it should be fixed. You can still use QSqlQuery with QSqlQueryModel.

        B Offline
        B Offline
        BamboozledBaboon
        wrote on last edited by
        #3

        @SGaist Do you mean to say it's up to pyside dev to fix internally and I should keep going like I am or is there something different I need to do?

        SGaistS 1 Reply Last reply
        0
        • B BamboozledBaboon

          @SGaist Do you mean to say it's up to pyside dev to fix internally and I should keep going like I am or is there something different I need to do?

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @BamboozledBaboon yes. By the way, which version of PySide6 are you using ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          B 1 Reply Last reply
          1
          • SGaistS SGaist

            @BamboozledBaboon yes. By the way, which version of PySide6 are you using ?

            B Offline
            B Offline
            BamboozledBaboon
            wrote on last edited by
            #5

            @SGaist 6.5.1.1

            SGaistS 1 Reply Last reply
            0
            • B BamboozledBaboon

              @SGaist 6.5.1.1

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then you should check the bug report system to see if there's something related and if not open a new ticket so it gets fixed.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              B 1 Reply Last reply
              0
              • SGaistS SGaist

                Then you should check the bug report system to see if there's something related and if not open a new ticket so it gets fixed.

                B Offline
                B Offline
                BamboozledBaboon
                wrote on last edited by
                #7

                @SGaist Well do. Thank you.

                SGaistS 1 Reply Last reply
                0
                • B BamboozledBaboon

                  @SGaist Well do. Thank you.

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Thanks !

                  Don't forget to post a link to the issue so it's easier to find.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  B 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Thanks !

                    Don't forget to post a link to the issue so it's easier to find.

                    B Offline
                    B Offline
                    BamboozledBaboon
                    wrote on last edited by
                    #9

                    @SGaist As requested https://bugreports.qt.io/browse/PYSIDE-2394

                    SGaistS 1 Reply Last reply
                    1
                    • B BamboozledBaboon

                      @SGaist As requested https://bugreports.qt.io/browse/PYSIDE-2394

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Thanks !

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved