[Qt-interest] Capture mouse Event

Ivan Kharin korsar.akvis at gmail.com
Thu Jan 29 11:11:05 CET 2009


> Ankit.

> Hi,
> I have my GUI made in Qt. The app has multiple views(pages). 
> Problem:
> If the user is not performing any operation for a specified amount
> of time, say 10 min, then i need to exit the application. How can i achive this?

> One way of doing this is reimplement mouseMoveEvent() for every
> view I have, and then maintain a timer. every time the user moves
> the mouse, the timer resets. If the timer expires, then the application exits.
> Is there a bteer way to implement the same.

0. Declare variable: int idleMinutes = 0;
1. Set event filter to qApp
2. In event_filter body, reset idleMinutes to zero if event is QInputEvent (keyboard or mouse)
3. Set QTimer with one minute interval
4. In timer_slot body, increment idleMinutes and call qApp->quit() if idleMinutes >= 10

-- 
Ivan Kharin




More information about the Qt-interest-old mailing list