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. C++ : call to temporary is a no-op
Forum Updated to NodeBB v4.3 + New Features

C++ : call to temporary is a no-op

Scheduled Pinned Locked Moved Solved General and Desktop
24 Posts 5 Posters 3.4k Views 3 Watching
  • 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.
  • MasterQM MasterQ

    @Christian-Ehrlicher said in C++ : call to temporary is a no-op:

    Object and QObject are two different things. An object is an instance of a class (c++ basics) , a QObject is a Qt (base) class.

    I never claimed object and QObject are the same thing. I mentioned the doc since @Pl45m4 said QSqlField would be a struct.

    @JonB said in C++ : call to temporary is a no-op:

    @MasterQ said in C++ : call to temporary is a no-op:

    full citation:

    You wrote/added this after I wrote about using QSqlRecord::setValue(). I am unclear: are you aware that what you show in your "full citation" is not the (best) way to read or write a value in a QSqlRecord (and you should change)? Just checking.

    I am not sure if I got you. You mean the version to address the field by name is better as to address by index, right? Since I have full controll about the structure of the database I also have full control of the sequence of the fields. I agree that by name is a safer way to do it. Maybe I will change in future. At the moment there are other issues with higher priority.

    While on the topic you mentioned "isn't everything in Qt a QObject" and you are investigating Qt, have you read Implicit Sharing?

    No, I was not aware of that topic. Thanks for pointing to.

    Christian EhrlicherC Online
    Christian EhrlicherC Online
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #21

    @MasterQ said in C++ : call to temporary is a no-op:

    I never claimed object and QObject are the same thing

    A QSqlField object can provide some meta-data about the field, ...

    meta-data? sounds like QObject.

    But you wrote it...

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    1 Reply Last reply
    1
    • MasterQM Offline
      MasterQM Offline
      MasterQ
      wrote on last edited by
      #22

      I want to close this thread for now.

      Learned a lot! Good day!

      Thank you guys and have a nice Feierabend.

      1 Reply Last reply
      0
      • MasterQM MasterQ has marked this topic as solved on
      • MasterQM MasterQ

        @Christian-Ehrlicher said in C++ : call to temporary is a no-op:

        Object and QObject are two different things. An object is an instance of a class (c++ basics) , a QObject is a Qt (base) class.

        I never claimed object and QObject are the same thing. I mentioned the doc since @Pl45m4 said QSqlField would be a struct.

        @JonB said in C++ : call to temporary is a no-op:

        @MasterQ said in C++ : call to temporary is a no-op:

        full citation:

        You wrote/added this after I wrote about using QSqlRecord::setValue(). I am unclear: are you aware that what you show in your "full citation" is not the (best) way to read or write a value in a QSqlRecord (and you should change)? Just checking.

        I am not sure if I got you. You mean the version to address the field by name is better as to address by index, right? Since I have full controll about the structure of the database I also have full control of the sequence of the fields. I agree that by name is a safer way to do it. Maybe I will change in future. At the moment there are other issues with higher priority.

        While on the topic you mentioned "isn't everything in Qt a QObject" and you are investigating Qt, have you read Implicit Sharing?

        No, I was not aware of that topic. Thanks for pointing to.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #23

        @MasterQ said in C++ : call to temporary is a no-op:

        I am not sure if I got you. You mean the version to address the field by name is better as to address by index, right?

        No. I am saying your way of coding, going via a QSqlField and commenting on the copying/temporaries etc. is "wrong", at least efficiency-/lines-of-code-wise, for both writing and reading your fields. (Nothing to do with integer indexing vs name indexing, they are just alternatives, integer indexing is faster.) You do not and should not need to access field() at all in either. You simply need:

        int id() const { return value(Id).toInt(); }
        void setId(int id) { setValue(Id, id); }
        

        and so on for all your field getters/setters. None of that 3-lines-to-set! Do not go via QSqlRecord::field() at all, forget about QSqlField, just use QSqlRecord::value()/setValue().

        1 Reply Last reply
        2
        • MasterQM Offline
          MasterQM Offline
          MasterQ
          wrote on last edited by
          #24

          Oh, that detail I have overseen. Uops.

          1 Reply Last reply
          1

          • Login

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