1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02:00

Add example for dani

This commit is contained in:
kelteseth 2018-11-06 16:59:10 +01:00
parent fe118766a3
commit 5e69677cf5
2 changed files with 24 additions and 0 deletions

View File

@ -7,6 +7,9 @@
CPU::CPU(QObject *parent) : QObject(parent)
{
m_updateTimer.start(m_updateTimer);
// signal obj, signal function pointer, slot obj, slot function pointer
connect(&m_updateTimer,&QTimer::timeout,this,&CPU::update);
}

View File

@ -2,6 +2,7 @@
#include <QObject>
#include <QDebug>
#include <QTimer>
#ifdef Q_OS_WIN
#include <qt_windows.h>
@ -15,6 +16,7 @@ class CPU : public QObject {
Q_OBJECT
Q_PROPERTY(float usage READ usage NOTIFY usageChanged)
Q_PROPERTY(int tickRate READ tickRate WRITE setTickRate NOTIFY tickRateChanged)
public:
explicit CPU(QObject* parent = nullptr);
@ -25,10 +27,17 @@ public:
return m_usage;
}
int tickRate() const
{
return m_tickRate;
}
signals:
void usageChanged(float usage);
void tickRateChanged(int tickRate);
public slots:
void update();
@ -42,6 +51,17 @@ public slots:
emit usageChanged(m_usage);
}
void setTickRate(int tickRate)
{
if (m_tickRate == tickRate)
return;
qDebug() << "hat sich was geändert";
m_tickRate = tickRate;
emit tickRateChanged(m_tickRate);
}
private:
float m_usage = 42.0f;
@ -53,4 +73,5 @@ private:
static int c_NumOfProcessors;
static ULONG c_BufferSize;
int m_tickRate;
};