Inhibiting the device screen saver using Qt
This snippet shows how to prevent the screen saver from activating in an application by using Qt Mobility's QSystemScreenSaver class.
Article Metadata
Tested with
Devices(s): Nokia E7-00, N8-00, N900
Compatibility
Platform(s): Symbian
Maemo
Maemo
Article
Keywords: QSystemScreenSaver
Created: kratsan
(27 Jan 2011)
Last edited: hamishwillee
(18 Oct 2012)
Contents |
Preconditions
Qt Mobility 1.0.2 or higher is installed.
Project configuration file (.pro) file
Add the Qt Mobility project configuration option in the .pro file as shown below.
CONFIG += mobility
MOBILITY += systeminfo
Header file
Add the inclusion of <QSystemScreenSaver>.
#include <QSystemScreenSaver>Add the QSystemScreenSaver object as member to your QObject-derived class and set the inhibiter to active by calling the setScreenSaverInhibit() method. The inhibiter will continue to prevent the screen saver from activating as long as the QSystemScreenSaver object exists.
class MyObject : public QObject
{
MyObject() {
bool success = screenSaverInhibiter.setScreenSaverInhibit();
if(success == false) {
// Failed to set the screen saver inhibiter.
// The platform may not have a default screen saver implementation
// or system policies may prevent the setting of the inhibiter.
}
}
protected:
QSystemScreenSaver screenSaverInhibiter;
};
Postconditions
The code snippet demonstrated a way to inhibit the screen saver from activating.


Hello,
I'm having trouble locating QSystemScreenSaver that is called for in the header file and thus get a compile error. I'm a newbie at this but finally have a phonon video player example running and have also modified it for repeating video on a Symbian3 phone using the Mobility Technology Preview. The only way I could get the video player to compile right was to uninstall all previously installed Qt components and reinstall mobility technology preview from this link: http://www.developer.nokia.com/info/sw.nokia.com/id/da8df288-e615-443d-be5c-00c8a72435f8/Qt_SDK.html Last step is to try and add the screen saver inhibit but I'm stuck. I did also find this bug report (https://bugreports.qt-project.org/browse//QTSDK-98) and tried moving the zipped files to the C:\QtSDK\Symbian\SDKs\Symbian3Qt471\epoc32\.. udeb directory but with no luck. Any further instruction would be great. I've gone in circles now with google search.
I'm using qt 4.7.3 and Qt Mobility 1.1.3 on Nokia N8 and when I invoke setScreenSaverInhibit(); the API return false on the device.How can I inhibit the screen saver? Thank you.