[Qt-interest] Detecting when OS going to sleep / going out of sleep
Castagne Nicolas
nicolascastagne at yahoo.fr
Thu Mar 24 10:21:49 CET 2011
Hi folks,
Is there a mean in Qt to detect when the OS is going to sleep and when the OS has just waked up ?
DETAILS :
On the Mac, Mac OS X.6 (but I guess should be the same on Windows), when Mac OS just wakes up after sleeping, various services are not accesible for a while (eg a few seconds), including the USB ports.
In our app, a QTimer accesses a USB port from time to time.
When the timer elapses right after the OS has waked up, the USB port is not accessible (and the app crashes, but that's another story).
=> we would need to stop the timer when the OS goes to sleep, restart it after a while when the OS has been awaked.
To that aim, we need detecting OS sleeping/unsleeping.
I found a tentative solution based on QEvent::ApplicationDeactivate here:
http://lists.qt.nokia.com/pipermail/qt-interest/2009-September/012876.html
but it is not totally appropriate.
Thanks much in advance,
Nicolas // Christophe
More information about the Qt-interest-old
mailing list