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
Forum Update on Monday, May 27th 2025

DeprecationWarning QSqlQueryModel.setQuery

Scheduled Pinned Locked Moved Unsolved Qt for Python
qt for pythonpythonpyside
10 Posts 2 Posters 976 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 13 Jul 2023, 18:49 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...

    S 1 Reply Last reply 13 Jul 2023, 18:55
    0
    • B BamboozledBaboon
      13 Jul 2023, 18:49

      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...

      S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 Jul 2023, 18:55 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 13 Jul 2023, 18:58
      0
      • S SGaist
        13 Jul 2023, 18:55

        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 13 Jul 2023, 18:58 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?

        S 1 Reply Last reply 13 Jul 2023, 19:02
        0
        • B BamboozledBaboon
          13 Jul 2023, 18:58

          @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?

          S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 13 Jul 2023, 19:02 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 13 Jul 2023, 19:05
          1
          • S SGaist
            13 Jul 2023, 19:02

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

            B Offline
            B Offline
            BamboozledBaboon
            wrote on 13 Jul 2023, 19:05 last edited by
            #5

            @SGaist 6.5.1.1

            S 1 Reply Last reply 13 Jul 2023, 19:06
            0
            • B BamboozledBaboon
              13 Jul 2023, 19:05

              @SGaist 6.5.1.1

              S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 13 Jul 2023, 19:06 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 13 Jul 2023, 19:09
              0
              • S SGaist
                13 Jul 2023, 19:06

                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 13 Jul 2023, 19:09 last edited by
                #7

                @SGaist Well do. Thank you.

                S 1 Reply Last reply 13 Jul 2023, 19:11
                0
                • B BamboozledBaboon
                  13 Jul 2023, 19:09

                  @SGaist Well do. Thank you.

                  S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 13 Jul 2023, 19:11 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 13 Jul 2023, 20:19
                  0
                  • S SGaist
                    13 Jul 2023, 19:11

                    Thanks !

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

                    B Offline
                    B Offline
                    BamboozledBaboon
                    wrote on 13 Jul 2023, 20:19 last edited by
                    #9

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

                    S 1 Reply Last reply 15 Jul 2023, 16:19
                    1
                    • B BamboozledBaboon
                      13 Jul 2023, 20:19

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

                      S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 15 Jul 2023, 16:19 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

                      3/10

                      13 Jul 2023, 18:58

                      topic:navigator.unread, 7
                      • Login

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