×
Namespaces

Variants
Actions
(Difference between revisions)

Inhibiting the device screen saver using Qt

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Addition to article of: Category:MeeGo Category:Symbian. (Add platform categories))
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update)
Line 1: Line 1:
 
[[Category:Qt]]
 
[[Category:Qt]]
{{KBCS}}
+
{{ArticleMetaData <!-- v1.2 -->
{{ArticleMetaData
+
|id=CS001657
+
|platform=Symbian<br>Maemo
+
|devices=Nokia E7-00, N8-00, N900
+
|category=Qt
+
|subcategory=Qt Mobility
+
|creationdate=February 9, 2010
+
|keywords=QSystemScreenSaver
+
 
+
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|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]]) -->
 
|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]) -->
+
|devices= Nokia E7-00, N8-00, N900
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|platform= Symbian<br>Maemo
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices.) -->
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|author=[[User:Kratsan]]
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= QSystemScreenSaver
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20110127
 +
|author= [[User:Kratsan]]
 +
<!-- The following are not in current metadata -->
 +
|subcategory= Qt Mobility
 +
|id= CS001657
 
}}
 
}}
  
 
==Overview==
 
==Overview==
  
This snippet shows how to prevent the screen saver from activating in an application by using Qt Mobility's <tt>QSystemScreenSaver</tt> class.
+
This snippet shows how to prevent the screen saver from activating in an application by using Qt Mobility's {{Icode|QSystemScreenSaver}} class.
  
 
==Preconditions==
 
==Preconditions==
Line 37: Line 44:
 
== Header file ==
 
== Header file ==
  
Add the inclusion of <tt><QSystemScreenSaver></tt>.
+
Add the inclusion of {{Icode|<QSystemScreenSaver>}}.
  
 
<code cpp>
 
<code cpp>
Line 43: Line 50:
 
</code>
 
</code>
  
Add the <tt>QSystemScreenSaver</tt> object as member to your <tt>QObject</tt>-derived class and set the inhibiter to active by calling the <tt>setScreenSaverInhibit()</tt> method. The inhibiter will continue to prevent the screen saver from activating as long as the <tt>QSystemScreenSaver</tt> object exists.
+
Add the {{Icode|QSystemScreenSaver}} object as member to your {{Icode|QObject}}-derived class and set the inhibiter to active by calling the {{Icode|setScreenSaverInhibit()}} method. The inhibiter will continue to prevent the screen saver from activating as long as the {{Icode|QSystemScreenSaver}} object exists.
  
 
<code cpp>
 
<code cpp>
Line 66: Line 73:
  
  
[[Category: Qt Mobility]][[Category:Code Examples]][[Category:Code Snippet]][[Category:MeeGo]] [[Category:Symbian]]
+
[[Category: Qt Mobility]][[Category:Code Snippet]][[Category:Code Snippet]][[Category:MeeGo]] [[Category:Symbian]]

Revision as of 09:52, 11 May 2012

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

Contents

Overview

This snippet shows how to prevent the screen saver from activating in an application by using Qt Mobility's 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 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.

117 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×