Namespaces
Variants
Actions
(Difference between revisions)

Inhibiting the device screen saver using Qt

Jump to: navigation, search
m (Hamishwillee - Addition to article of: Category:MeeGo Category:Symbian. (Add platform categories))
m (Hamishwillee - Add Abstract. Improve categories)
 
(6 intermediate revisions by one user not shown)
Line 1: Line 1:
[[Category:Qt]]
+
[[Category:Qt]][[Category:Qt Mobility]][[Category:MeeGo Harmattan]][[Category:Symbian]][[Category:UI]][[Category:Base/System]][[Category:Code Snippet]][[Category:Symbian^3]][[Category:Nokia Belle]]
{{KBCS}}
+
{{Abstract|This snippet shows how to prevent the screen saver from activating in an application by using Qt Mobility's {{Icode|QSystemScreenSaver}} class.}}
{{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
+
  
 +
{{ArticleMetaData <!-- v1.2 -->
 
|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 -->
 +
|id= CS001657
 
}}
 
}}
 
==Overview==
 
 
This snippet shows how to prevent the screen saver from activating in an application by using Qt Mobility's <tt>QSystemScreenSaver</tt> class.
 
  
 
==Preconditions==
 
==Preconditions==
Line 30: Line 34:
  
 
Add the Qt Mobility project configuration option in the .pro file as shown below.
 
Add the Qt Mobility project configuration option in the .pro file as shown below.
<code cpp>
+
<code cpp-qt>
 
CONFIG += mobility
 
CONFIG += mobility
 
MOBILITY += systeminfo
 
MOBILITY += systeminfo
Line 37: Line 41:
 
== Header file ==
 
== Header file ==
  
Add the inclusion of <tt><QSystemScreenSaver></tt>.
+
Add the inclusion of {{Icode|<QSystemScreenSaver>}}.
  
<code cpp>
+
<code cpp-qt>
 
#include <QSystemScreenSaver>
 
#include <QSystemScreenSaver>
 
</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-qt>
 
class MyObject : public QObject
 
class MyObject : public QObject
 
{
 
{
Line 64: Line 68:
  
 
The code snippet demonstrated a way to inhibit the screen saver from activating.
 
The code snippet demonstrated a way to inhibit the screen saver from activating.
 
 
[[Category: Qt Mobility]][[Category:Code Examples]][[Category:Code Snippet]][[Category:MeeGo]] [[Category:Symbian]]
 

Latest revision as of 01:20, 18 October 2012

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

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.

This page was last modified on 18 October 2012, at 01:20.
231 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved