Namespaces
Variants
Actions
(Difference between revisions)

Inhibiting the device screen saver using Qt

Jump to: navigation, search
m (minor spelling)
Line 1: Line 1:
 
[[Category:Qt]]
 
[[Category:Qt]]
 +
{{KBCS}}
 
{{CodeSnippet
 
{{CodeSnippet
|id=
+
|id=CS001657
 
|platform=Symbian<br>Maemo
 
|platform=Symbian<br>Maemo
|devices=E7, N8, N900
+
|devices=Nokia E7-00, N8-00, N900
 
|category=Qt
 
|category=Qt
 
|subcategory=Qt Mobility
 
|subcategory=Qt Mobility
|creationdate=January 27, 2010
+
|creationdate=February 9, 2010
 
|keywords=QSystemScreenSaver
 
|keywords=QSystemScreenSaver
 
}}
 
}}
Line 12: Line 13:
 
==Overview==
 
==Overview==
  
This snippet shows how to prevent 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 <tt>QSystemScreenSaver</tt> class.
  
 
==Preconditions==
 
==Preconditions==
 +
 
Qt Mobility 1.0.2 or higher is installed.
 
Qt Mobility 1.0.2 or higher is installed.
  
 
== Project configuration file (.pro) file ==
 
== Project configuration file (.pro) file ==
  
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>
 
CONFIG += mobility
 
CONFIG += mobility
Line 33: Line 35:
 
</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 <tt>setScreenSaverInhibit()</tt> method. The inhibiter will continue to prevent screen saver from activating as long as the <tt>QSystemScreenSaver</tt> object exists.
+
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.
  
 
<code cpp>
 
<code cpp>

Revision as of 11:56, 9 February 2011

Template:KBCS

Article Metadata

Tested with
Devices(s): Nokia E7-00, N8-00, N900

Compatibility
Platform(s): Symbian
Maemo

Article
Keywords: QSystemScreenSaver
Created: (09 Feb 2010)
Last edited: Forum Nokia KB (09 Feb 2011)

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.

215 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