How to detect any user interaction on monitor
I have problem in detecting any user interaction on monitor. I need to know if user interacts with monitor or not for a specified period.
For example, If there isn't any interactions for 5 minutes, set the brightness to lowest value for power saving. The interactions may be clicking on buttons, flicking... or even touching anywhere on the monitor (I mean that touching a non-object on monitor).
Can I do it on QML layer? (I have many screens)
I prefer doing it on C++ layer.
I understand you have a full-screen application? Then you can put a MouseArea on the main view, stretch it so that it covers the whole app window, and detect clicks there. You just need to remember not to block events for underlying UI, so set
event.accepted = falsein your slots.
@sierdzio Thank you for your suggestion.
Yes, I have a full-screen application.
But I think it is not a good way. I actually have 1 main view, but have a lot of screens which are loaded by Loader. Each screen contains several items (buttons, listview, etc). By your way, I have to catch even from every buttons, listview,... right? It will be a big thing to do.
By your way, I have to catch even from every buttons, listview,... right? It will be a big thing to do.
No, the contrary in fact. I suggest making one, single, top-level MouseArea. Put your user interaction checking code there (in any slot you need to support), then allow all mouse events to pass through that MouseArea by setting accepted to false. This way all events will be passed down to other QML elements you have. You only need to modify that top-level MouseArea, the rest of your application stays the same.