August 2018
Intermediate to advanced
534 pages
11h 21m
English
Let's take a look at the Mac implementation of the SysInfo class. Start by creating a new C++ class named SysInfoMacImpl, which inherits from the SysInfo class. Override the SysInfo virtual functions and you should have a SysInfoMacImpl.h file, such as this:
#include "SysInfo.h"
#include <QtGlobal>
#include <QVector>
class SysInfoMacImpl : public SysInfo
{
public:
SysInfoMacImpl();
void init() override;
double cpuLoadAverage() override;
double memoryUsed() override;
};
The first implementation we will do is the memoryUsed() function, in the SysInfoMacImpl.cpp file:
#include "SysInfoMacImpl.h"#include <mach/vm_statistics.h> #include <mach/mach_types.h> #include <mach/mach_init.h> #include <mach/mach_host.h> ...
Read now
Unlock full access