(Difference between revisions)

Inhibiting the device screen saver using Qt

From Nokia Developer Wiki
Jump to: navigation, search
Forum Nokia KB (Talk | contribs)
m (Protected "CS001657 - Inhibiting the screen saver" ([edit=sysop] (indefinite) [move=sysop] (indefinite)))
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot change of template (Template:CodeSnippet) - now using Template:ArticleMetaData)
Line 1: Line 1:
Line 9: Line 9:
|creationdate=February 9, 2010
|creationdate=February 9, 2010
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices.) -->

Revision as of 12:28, 24 June 2011


Article Metadata
Tested with
Devices(s): Nokia E7-00, N8-00, N900
Platform(s): Symbian
Nokia Belle
Keywords: QSystemScreenSaver
Created: kratsan (09 Feb 2010)
Last edited: hamishwillee (24 Jun 2011)



This snippet shows how to prevent the screen saver from activating in an application by using Qt Mobility's QSystemScreenSaver class.


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.
QSystemScreenSaver screenSaverInhibiter;


The code snippet demonstrated a way to inhibit the screen saver from activating.

80 page views in the last 30 days.