Get the timestamp when a QInputEvent was put onto

2019-03-04 16:49发布

问题:

This question is closely related to QEventLoop: get time when an event was scheduled. Here I'm asking specifically about input events in contrast to "all kinds of events". I'm also interested in a solution for Qt 4.8.

For QInputEvent in Qt 5 there is a timestamp() member method that can be used. In Qt 4.8 there is no such method. Are there any other approaches to get the timestamp when an input event was initially "emitted" by driver/deeper systems. Or when it was initially "received" by Qt and put onto the event queue?

回答1:

I took a look into the different keyboard/input drivers in embedded Qt and found that there is no handling of timestamps whatsoever. So the available default implementations where not satisfying.

I managed to get the timestamps by implementing my own logic on my specific platform. In my case this required reading from dev/input/event file and creating the QInput events by myself. Each keyboard input also contains a timestamp which seems to be the timestamp when the input happened.



标签: c++ qt qt4.8