Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6075025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:26:53+00:00 2026-05-23T10:26:53+00:00

How to detect when a GUI application has been idle, (ie, no user interaction),

  • 0

How to detect when a GUI application has been idle, (ie, no user interaction), for a period of time ?

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.

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.

CustomEventFilter::CustomEventFilter(QObject *parent) :
    QObject(parent)
{   
    m_timer.setInterval(5000);
    connect(&m_timer,SIGNAL(timeout()),this,SLOT(ResetTimer()));
}

bool CustomEventFilter::eventFilter(QObject *obj, QEvent *ev)
{
    if(ev->type() == QEvent::KeyPress ||
           ev->type() == QEvent::MouseMove)
    {
        ResetTimer();
        return QObject::eventFilter(obj, ev);

     }
    else
    {

    }
}

bool CustomEventFilter::ResetTimer()
{
    m_timer.stop(); // reset timer

}

And my main.cpp looks like this :

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainForm w;
    w.show();
    CustomEventFilter filter;
    a.installEventFilter(&filter);

    return a.exec();


}

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:26:54+00:00Added an answer on May 23, 2026 at 10:26 am

    Override QCoreApplication::notify and a timer on mouse/keyboard events?

    (Or just store the time of the event and have a timer check that value periodically, which might be faster than resetting a timer all the time.)

    class QMyApplication : public QApplication
    {
    public:
        QTimer m_timer;
    
        QMyApplication() {
            m_timer.setInterval(5000);
            connect(&m_timer, SIGNAL(timeout()), this, SLOT(app_idle_for_five_secs());
            m_timer.start();
        }
    slots:
        bool app_idle_for_five_secs() {
            m_timer.stop();
            // ...
        }
    protected:
        bool QMyApplication::notify ( QObject * receiver, QEvent * event )
        {
            if (event->type == QEvent::MouseMove || event->type == QEvent::KeyPress) {
                 m_timer.stop(); // reset timer
                 m_timer.start();
            }    
            return QApplicaiton::notify(receiver, event);
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I detect when an Exception has been thrown anywhere in my application?
I am trying to detect if an element has been scrolled out and have
So basically I have a plugin dll that is loaded by a GUI-Application. In
I have an application, let's call it myapp.exe, which is dual-mode console/GUI, built as
I have a GUI application that doesn't have a memory leak. I have confirmed
My application has to detect that the device connected to the Wi-Fi network is
You can detect whether a popup has been blocked in Chrome with the solutions
I need to detect when a session has expired in my Visuial Basic web
How do I detect if the system has a default recording device installed? I
How do I detect what browser (IE, Firefox, Opera) the user is accessing my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.