Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
QVector<qulonglong> SysInfoLinuxImpl::cpuRawData()
{
QFile file("/proc/stat");
file.open(QIODevice::ReadOnly);
QByteArray line = file.readLine();
file.close();
qulonglong totalUser = 0, totalUserNice = 0,
totalSystem = 0, totalIdle = 0;
std::sscanf(line.data(), "cpu %llu %llu %llu %llu",
&totalUser, &totalUserNice, &totalSystem,
&totalIdle);
QVector<qulonglong> rawData;
rawData.append(totalUser);
rawData.append(totalUserNice);
rawData.append(totalSystem);
rawData.append(totalIdle);
return rawData;
}


What I have tried:

I tried looking at it. I am not able to get it figured out.
Posted
Updated 4-Nov-20 22:47pm
Comments
Joe Woodbury 4-Nov-20 15:29pm    
What is there to figure out? It's a Qt vector class.

It is a Qvector of type qulonglong. It has four values placed in it and it is returned from the function.

Beyond that you will have to look more closely at its implementation.
 
Share this answer
 
It reads process information from the Linux/UNIX system and extracts details of processor time spent in the various states. It returns the details in a QVector object.
 
Share this answer
 
What about the documentation: QVector Class | Qt Core 5.15.1[^] ?
See also QTL or STL? | CodeImproved[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900