C
C
CheGevara2014-06-18 16:00:15
Programming
CheGevara, 2014-06-18 16:00:15

How to track user inactivity in QT?

There is a project on QT (Widgets) | Ubuntu OS, but Windows is also possible |
There is a timer in the project that must be reset if the user does something ... at least presses the keys, even moves the mouse around the screen (roughly speaking, the timer action should occur if the user does nothing).
Let's simplify the task: the program works in fullscreen (i.e. you don't need to follow the actions outside the form/widget).
Question: how? =)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
EXL, 2014-06-19
@CheGevara

For Qt, there is an additional library - Qxt, in the tests there is an application that demonstrates just what you need: idle time is displayed in the window title when the user moves the mouse or presses a key or performs some other action - the counter is reset.
You can use Qxt in your project (versions for Mac OS, Win and Linux are available), or pull out the implementation of the idleTime() function for various systems:
Win , X11 (GNU/Linux) , Mac OS .
You can download Qxt here .

M
Misha Krinkin, 2014-06-18
@kmu1990

All descendants of QObject have eventFilter and installEventFilter methods. You just call installEventFilter on the object you want to watch and pass it a pointer to the object that will watch it (maybe just a pointer to yourself):
qt-project.org/doc/qt-4.8/qobject.html#eventFilter

K
Kyberman, 2014-06-18
@Kyberman

If in fullscreen, then do QWidget::setMouseTracking(true), override the mouseMoveEvent() method and reset the timer in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question