问题
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.
来源:https://stackoverflow.com/questions/52816955/get-the-timestamp-when-a-qinputevent-was-put-onto-the-queue-of-the-qeventloop-in