Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. do i have to delete query object pointer?
Forum Update on Monday, May 27th 2025

do i have to delete query object pointer?

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 2 Posters 1.3k 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 29 Jul 2019, 19:09 last edited by
    #4

    Why do you need to store that query as member variable ?

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

    U 1 Reply Last reply 29 Jul 2019, 19:13
    0
    • S SGaist
      29 Jul 2019, 19:09

      Why do you need to store that query as member variable ?

      U Offline
      U Offline
      user4592357
      wrote on 29 Jul 2019, 19:13 last edited by
      #5

      @sgaist
      well i'm creating and executing the query in a data source class (for table view), then each colomn takes the query from the data source and gets appropriate value from it.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 29 Jul 2019, 19:17 last edited by
        #6

        Then you should rather keep the string of the query and build the QSqlQuery object when you actually need it.

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

        U 1 Reply Last reply 29 Jul 2019, 19:18
        1
        • S SGaist
          29 Jul 2019, 19:17

          Then you should rather keep the string of the query and build the QSqlQuery object when you actually need it.

          U Offline
          U Offline
          user4592357
          wrote on 29 Jul 2019, 19:18 last edited by
          #7

          @sgaist
          then how will the columns get the results?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 29 Jul 2019, 19:23 last edited by
            #8

            Can you share the code you are using ?
            It looks like you could make use of a QSqlQueryModel.

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

            U 1 Reply Last reply 29 Jul 2019, 19:26
            0
            • S SGaist
              29 Jul 2019, 19:23

              Can you share the code you are using ?
              It looks like you could make use of a QSqlQueryModel.

              U Offline
              U Offline
              user4592357
              wrote on 29 Jul 2019, 19:26 last edited by user4592357
              #9

              @sgaist
              no i'm on mobile now, and soon to sleep. will take a look at it tomorrow and see if i can use it. thanks

              U 1 Reply Last reply 5 Aug 2019, 05:41
              0
              • U user4592357
                29 Jul 2019, 19:26

                @sgaist
                no i'm on mobile now, and soon to sleep. will take a look at it tomorrow and see if i can use it. thanks

                U Offline
                U Offline
                user4592357
                wrote on 5 Aug 2019, 05:41 last edited by
                #10

                @SGaist
                i took a look at QSqlQueryModel but i guess i can't use it because my table view already has a model.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 5 Aug 2019, 20:31 last edited by
                  #11

                  What kind ?

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

                  U 1 Reply Last reply 6 Aug 2019, 06:10
                  0
                  • S SGaist
                    5 Aug 2019, 20:31

                    What kind ?

                    U Offline
                    U Offline
                    user4592357
                    wrote on 6 Aug 2019, 06:10 last edited by
                    #12

                    @sgaist
                    it is QAbstractTableModel

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 6 Aug 2019, 20:58 last edited by
                      #13

                      You can replace your model unless you are doing something special with it ?

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

                      U 1 Reply Last reply 7 Aug 2019, 04:37
                      0
                      • S SGaist
                        6 Aug 2019, 20:58

                        You can replace your model unless you are doing something special with it ?

                        U Offline
                        U Offline
                        user4592357
                        wrote on 7 Aug 2019, 04:37 last edited by
                        #14

                        @sgaist
                        that's the thing. i can't replace it cause it's doing a lot of things (it's part of a library someone has created and I'm using it)

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 7 Aug 2019, 06:23 last edited by
                          #15

                          How are you using it since you need to query a database ?

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

                          U 1 Reply Last reply 7 Aug 2019, 17:01
                          0
                          • S SGaist
                            7 Aug 2019, 06:23

                            How are you using it since you need to query a database ?

                            U Offline
                            U Offline
                            user4592357
                            wrote on 7 Aug 2019, 17:01 last edited by
                            #16

                            @sgaist
                            it has some long logic built into it, it sets up a lot of connections etc.

                            1 Reply Last reply
                            0

                            13/16

                            6 Aug 2019, 20:58

                            • Login

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