Hi I’m trying to figure out how to detect when my Windows Qt program resumes from sleep and handle the event appropriately. This looks like half the story with the RegisterPowerSettingNotification function. The other half is how to make this work in Qt.
If my research is correct it looks like you need a WndProc() override to handle events and the Qt equivalent is QWidget::nativeEvent. If this is correct then the question is how to detect the appropriate event in the nativeEvent override. Can anybody enlighten?
Also the OP in the linked post used the GUID_SESSION_DISPLAY_STATUS power setting GUID for the RegisterPowerSettingNotification call which detects when the display turns on/off/dims. Which I’d think is not the same as detecting a sleep event.
An alternative to the RegisterPowerSettingNotification approach could be to use QCoreApplication::installNativeEventFilter as per here. Is this a better way?
Also it looks like one last alternative is to use the PowerRegisterSuspendResumeNotification function but I’m not sure how that guy would link to the callback function; maybe PowerRegisterSuspendResumeNotification is a synchronous function call or the callback function gets called from the event loop?
Thanks!