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. Q_DISABLE_COPY(Systeminfo),'Systeminfo' does not name a type
Forum Updated to NodeBB v4.3 + New Features

Q_DISABLE_COPY(Systeminfo),'Systeminfo' does not name a type

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 4 Posters 1.1k Views 1 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.
  • S Offline
    S Offline
    shree_121
    wrote on 15 Aug 2019, 07:31 last edited by
    #3

    #there's no need for this macro there since QObject is not copyable so SystemInfo is also not copyable.
    hello @Christian-Ehrlicher , do you mean that I should remove Q_DISABLE_COPY(SystemInfo) line and compile again?

    M 1 Reply Last reply 15 Aug 2019, 07:46
    0
    • S shree_121
      15 Aug 2019, 07:31

      #there's no need for this macro there since QObject is not copyable so SystemInfo is also not copyable.
      hello @Christian-Ehrlicher , do you mean that I should remove Q_DISABLE_COPY(SystemInfo) line and compile again?

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 15 Aug 2019, 07:46 last edited by
      #4

      @shree_121
      Yes. as QObject handles that for you.
      Clean your build folder and try to compile again.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        shree_121
        wrote on 15 Aug 2019, 07:58 last edited by
        #5

        now i am getting error as 'SystemInfo' has not been declared .

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 15 Aug 2019, 08:39 last edited by
          #6

          @shree_121 said in Q_DISABLE_COPY(Systeminfo),'Systeminfo' does not name a type:

          now i am getting error as 'SystemInfo' has not been declared .

          Then you've another problem somewhere else - please show the complete error message and also make sure that no other header defines 'SYSTEMINFO_H'

          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
          0
          • S Offline
            S Offline
            shree_121
            wrote on 15 Aug 2019, 08:50 last edited by
            #7

            @Christian-Ehrlicher, @mrjj thank you so much now it built successfully, Can you tell me how can i print my OS kernel type in console using QString SystemInfo::kernelType() const.

            M 1 Reply Last reply 15 Aug 2019, 09:13
            0
            • S shree_121
              15 Aug 2019, 08:50

              @Christian-Ehrlicher, @mrjj thank you so much now it built successfully, Can you tell me how can i print my OS kernel type in console using QString SystemInfo::kernelType() const.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 15 Aug 2019, 09:13 last edited by
              #8

              @shree_121
              use std:.cout ?
              if console app ?
              or qDebug()

              1 Reply Last reply
              0
              • S Offline
                S Offline
                shree_121
                wrote on 15 Aug 2019, 09:46 last edited by shree_121
                #9

                ohh i used std::cout(console application) but exactly i am not sure where i have to write. Do i have to use signal and slot in main.cpp to execute QString SystemInfo::kernelType() const in systeminfo.cpp. please reply it will really help me.

                J 1 Reply Last reply 15 Aug 2019, 10:25
                0
                • M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 15 Aug 2019, 10:23 last edited by
                  #10

                  Hi
                  its just a function call so no need for signal or anything complex.
                  Note that std::xxx is buffered with Qt and you must flush it to print at once.

                  std::cout << "my type=" << QSysInfo::kernelType().toStdString() << std::flush;

                  this is for the Qt class. but its the same syntax with your wrapper.

                  1 Reply Last reply
                  1
                  • S shree_121
                    15 Aug 2019, 09:46

                    ohh i used std::cout(console application) but exactly i am not sure where i have to write. Do i have to use signal and slot in main.cpp to execute QString SystemInfo::kernelType() const in systeminfo.cpp. please reply it will really help me.

                    J Offline
                    J Offline
                    JonB
                    wrote on 15 Aug 2019, 10:25 last edited by JonB
                    #11

                    @shree_121
                    No signals/slots. Did you try something like:

                    SystemInfo si;
                    std::cout << si.kernelType().toStdString() << std::flush;
                    

                    As an architectural comment: all the methods of Qt's QSysInfo are static. Not sure what you are trying to add by creating a wrapper class deriving from QObject, requiring instantiating and with a QObject parent, etc. For example, you could never have written your SystemInfo class and simply called

                    std::cout << SystemInfo::kernelType().toStdString() << std::flush;
                    

                    Up to you.

                    @mrjj

                    but its the same syntax with your wrapper.

                    Similar, but the way he's written it a SystemInfo instance will need creating to call his methods.

                    M 1 Reply Last reply 15 Aug 2019, 10:37
                    2
                    • J JonB
                      15 Aug 2019, 10:25

                      @shree_121
                      No signals/slots. Did you try something like:

                      SystemInfo si;
                      std::cout << si.kernelType().toStdString() << std::flush;
                      

                      As an architectural comment: all the methods of Qt's QSysInfo are static. Not sure what you are trying to add by creating a wrapper class deriving from QObject, requiring instantiating and with a QObject parent, etc. For example, you could never have written your SystemInfo class and simply called

                      std::cout << SystemInfo::kernelType().toStdString() << std::flush;
                      

                      Up to you.

                      @mrjj

                      but its the same syntax with your wrapper.

                      Similar, but the way he's written it a SystemInfo instance will need creating to call his methods.

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 15 Aug 2019, 10:37 last edited by
                      #12

                      @jonb
                      thx for clearing up the difference between needing an instance and having static functions. :)
                      Its an important distinction.

                      J 1 Reply Last reply 15 Aug 2019, 11:26
                      0
                      • M mrjj
                        15 Aug 2019, 10:37

                        @jonb
                        thx for clearing up the difference between needing an instance and having static functions. :)
                        Its an important distinction.

                        J Offline
                        J Offline
                        JonB
                        wrote on 15 Aug 2019, 11:26 last edited by JonB
                        #13

                        @mrjj
                        The OP's instance approach would be fine if/when he has something to put in the instance to make it have a point. He may well do that, just at the moment there is no indication of what he might store in it, nor what connection it would have to a QObject or parent. Anyway I just mentioned so that he is aware he will need to create an instance, which he might not be.

                        M 1 Reply Last reply 15 Aug 2019, 11:45
                        0
                        • J JonB
                          15 Aug 2019, 11:26

                          @mrjj
                          The OP's instance approach would be fine if/when he has something to put in the instance to make it have a point. He may well do that, just at the moment there is no indication of what he might store in it, nor what connection it would have to a QObject or parent. Anyway I just mentioned so that he is aware he will need to create an instance, which he might not be.

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 15 Aug 2019, 11:45 last edited by
                          #14

                          @jonb
                          Indeed.
                          Also, such wrapper would be useful for exposing it to QML.

                          J 1 Reply Last reply 15 Aug 2019, 11:52
                          0
                          • M mrjj
                            15 Aug 2019, 11:45

                            @jonb
                            Indeed.
                            Also, such wrapper would be useful for exposing it to QML.

                            J Offline
                            J Offline
                            JonB
                            wrote on 15 Aug 2019, 11:52 last edited by
                            #15

                            @mrjj said in Q_DISABLE_COPY(Systeminfo),'Systeminfo' does not name a type:

                            Also, such wrapper would be useful for exposing it to QML.

                            Ah, that I would not have known. As I said, OP may have his reasons.

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              shree_121
                              wrote on 16 Aug 2019, 02:02 last edited by
                              #16

                              @mrjj , @JonB Both ways worked for me. Thank you.

                              1 Reply Last reply
                              1

                              12/16

                              15 Aug 2019, 10:37

                              • Login

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