×
Namespaces

Variants
Actions
(Difference between revisions)

Inhibiting the device screen saver using Qt

From Nokia Developer Wiki
Jump to: navigation, search
kratsan (Talk | contribs)
(Created page with 'Category:Qt {{CodeSnippet |id= |platform=Symbian<br>Maemo |devices=E7, N8, N900 |category=Qt |subcategory=Qt Mobility |creationdate=January 27, 2010 |keywords=QSystemScreenSa…')
 
kratsan (Talk | contribs)
Line 15: Line 15:
  
 
==Preconditions==
 
==Preconditions==
Qt Mobility 1.02 or higher is installed.
+
Qt Mobility 1.0.2 or higher is installed.
  
 
== Project configuration file (.pro) file ==
 
== Project configuration file (.pro) file ==
Line 56: Line 56:
  
  
[[Category:Qt]][[Category: Qt Mobility]][[Category:Code Examples]][[Category:Code Snippet]]
+
[[Category: Qt Mobility]][[Category:Code Examples]][[Category:Code Snippet]]

Revision as of 13:03, 27 January 2011

Article Metadata
Tested with
Devices(s): E7, N8, N900
Compatibility
Platform(s): Symbian
Maemo
Symbian
Nokia Belle
Symbian^3
Article
Keywords: QSystemScreenSaver
Created: (27 Jan 2010)
Last edited: kratsan (27 Jan 2011)

Contents

Overview

This snippet shows how to prevent screen saver from activating in an application by using Qt Mobilitys QSystemScreenSaver class.

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 setScreenSaverInhibit() method. The inhibiter will continue to prevent 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.

138 page views in the last 30 days.
×