From 5e69677cf57dd7229f56f862348d0f208ccc4f4c Mon Sep 17 00:00:00 2001 From: kelteseth Date: Tue, 6 Nov 2018 16:59:10 +0100 Subject: [PATCH] Add example for dani --- ScreenPlaySysInfo/cpu.cpp | 3 +++ ScreenPlaySysInfo/cpu.h | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/ScreenPlaySysInfo/cpu.cpp b/ScreenPlaySysInfo/cpu.cpp index da602d8e..072fae8a 100644 --- a/ScreenPlaySysInfo/cpu.cpp +++ b/ScreenPlaySysInfo/cpu.cpp @@ -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); } diff --git a/ScreenPlaySysInfo/cpu.h b/ScreenPlaySysInfo/cpu.h index a730be0c..82699a17 100644 --- a/ScreenPlaySysInfo/cpu.h +++ b/ScreenPlaySysInfo/cpu.h @@ -2,6 +2,7 @@ #include #include +#include #ifdef Q_OS_WIN #include @@ -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; };