Qt key press event stops working after resumed from system suspension

I am running a Qt application on an IMX6ULL (Yocto build project). The application works fine normally, but after resuming from a system standby low power mode (wake up by uart), the Qt application stops receiving further key press events. The keyPressEvent() function doesn’t get called at all. The /dev/input/event0 however seems to continue to register the key press condition.

Hi @sslee,

first, welcome to our community! Feel free to ask any questions you might have.

Regarding your question, which version of Yocto and which image are you using? (for example, dunfell, tdx-multimedia-image…)

Do you see the same behavior when waking up from another source? For Colibri iMX6ULL, you can use the SODIMM PIN 45 (need to be pulled up or down, depending on the previous state), or use the RTC.

Reference: Suspend/Resume (Linux) | Toradex Developer Center

Best Regards,

The problem is your wakeup logic grabbed focus from the Qt application. You need to force focus back to the Qt application then keypress will route to it.

Hi @seasoned_geek
I am very new to Qt… How do I force focus back to the application? My thinking is right now:

  1. create a thread to emit a “watchdog” signal every x seconds
  2. connect the signal to a “watchdog function” in MainWindow
  3. if the “watchdog function” finds a gap on the “watchdog” signals (due to system suspension), then it forces the focus back to the application (but how? please advise)

Does this logic make sense? Are there any other better way to determine if the application resumes from system suspension?

I can’t advise you without knowing the entirety of your application and if it is subject to RISK analysis like a medical device is. I can tell you to read this.


I can also tell you that in the code that “wakes up” the system you can have it write to a socket or a virtual UART or any thing that your main application is “listening” on. When your main application gets the “I just woke up” boot to the head, you have your application grab keyboard focus.

Don’t try to bandage this within your own application. The “wake up” code has to wake the application up properly. Your team skipped that step.