Q_DISABLE_COPY(Systeminfo),'Systeminfo' does not name a type
-
#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? -
#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?@shree_121
Yes. as QObject handles that for you.
Clean your build folder and try to compile again. -
@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'
-
@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.
@shree_121
use std:.cout ?
if console app ?
or qDebug() -
-
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.
-
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.
@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
arestatic
. Not sure what you are trying to add by creating a wrapper class deriving fromQObject
, requiring instantiating and with aQObject
parent, etc. For example, you could never have written yourSystemInfo
class and simply calledstd::cout << SystemInfo::kernelType().toStdString() << std::flush;
Up to you.
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. -
@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
arestatic
. Not sure what you are trying to add by creating a wrapper class deriving fromQObject
, requiring instantiating and with aQObject
parent, etc. For example, you could never have written yourSystemInfo
class and simply calledstd::cout << SystemInfo::kernelType().toStdString() << std::flush;
Up to you.
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. -
@jonb
thx for clearing up the difference between needing an instance and having static functions. :)
Its an important distinction.@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 aQObject
or parent. Anyway I just mentioned so that he is aware he will need to create an instance, which he might not be. -
@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 aQObject
or parent. Anyway I just mentioned so that he is aware he will need to create an instance, which he might not be.