title: How to detect if a Qt GUI application has been idle, inside the app itself (Qt)?
body: <p>How to detect when a GUI application has been idle, (ie, no user interaction), for a period of time ?</p>
  
  <p>I have n number of Qt Screens , I want to bring Date-Time screen when application is idle for 5 seconds and when i click on Date-Time screen it should return back to the last screen.</p>
  
  <p>Currently I am using below code, now how to check if system is idle for 5 seconds bring a new form and when some body mousemove/click it should go back to the last form. </p>
  
  <pre><code>CustomEventFilter::CustomEventFilter(QObject *parent) :
      QObject(parent)
  {   
      m_timer.setInterval(5000);
      connect(&amp;m_timer,SIGNAL(timeout()),this,SLOT(ResetTimer()));
  }
  
  bool CustomEventFilter::eventFilter(QObject *obj, QEvent *ev)
  {
      if(ev-&gt;type() == QEvent::KeyPress ||
             ev-&gt;type() == QEvent::MouseMove)
      {
          ResetTimer();
          return QObject::eventFilter(obj, ev);
  
       }
      else
      {
  
      }
  }
  
  bool CustomEventFilter::ResetTimer()
  {
      m_timer.stop(); // reset timer
  
  }
  </code></pre>
  
  <p>And my main.cpp looks like this :</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      MainForm w;
      w.show();
      CustomEventFilter filter;
      a.installEventFilter(&amp;filter);
  
      return a.exec();
  
  
  }
  </code></pre>
  
  <p>Thanks.</p>