#include <QThread>
#include <QTime>
#include <iostream>

class Thread : public QThread
{
   private:
      int    cnt;
      int    t1el;
      int    t2el;
      double fps;
      QTime  t1;
      QTime  t2;
   public:
      virtual void run();
};

void Thread::run()
{
   cnt=0;
   fps=0;
   t1.start();
   t2.start();

   forever
   {
      t1el=t1.elapsed();
      t2el=t2.elapsed();
      if(t2el>0)
      {
         fps=cnt*1000/t2el;
      }
      if(t1el>1)
      {
         cnt++;
         t1.start();
         std::cout<<"Counter: "<<cnt<<", elpased: "<<t2el<<", fps: "<<fps<<std::endl;
      }
   }
}

int main()
{
   Thread thr;
   thr.start();
   thr.wait();
}
