×
Namespaces

Variants
Actions
(Difference between revisions)

Inhibiting the device screen saver using Qt

From Nokia Developer Wiki
Jump to: navigation, search
chintandave_er (Talk | contribs)
m (minor spelling)
hamishwillee (Talk | contribs)
m (Hamishwillee - Add Abstract. Improve categories)
 
(11 intermediate revisions by 2 users 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]]
{{CodeSnippet
+
{{Abstract|This snippet shows how to prevent the screen saver from activating in an application by using Qt Mobility's {{Icode|QSystemScreenSaver}} class.}}
|id=
+
 
|platform=Symbian<br>Maemo
+
{{ArticleMetaData <!-- v1.2 -->
|devices=E7, N8, N900
+
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
|category=Qt
+
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|subcategory=Qt Mobility
+
|devices= Nokia E7-00, N8-00, N900
|creationdate=January 27, 2010
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|keywords=QSystemScreenSaver
+
|platform= Symbian<br>Maemo
 +
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 +
|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==
+
==Preconditions==
  
This snippet shows how to prevent screen saver from activating in an application by using Qt Mobility's <tt>QSystemScreenSaver</tt> class.
 
 
==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-qt>
 
CONFIG += mobility
 
CONFIG += mobility
 
MOBILITY += systeminfo
 
MOBILITY += systeminfo
Line 27: 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 <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 {{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 54: 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]]
 

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
Symbian
Nokia Belle
Symbian^3
Article
Keywords: QSystemScreenSaver
Created: kratsan (27 Jan 2011)
Last edited: hamishwillee (18 Oct 2012)

Contents

[edit] Preconditions

Qt Mobility 1.0.2 or higher is installed.

[edit] Project configuration file (.pro) file

Add the Qt Mobility project configuration option in the .pro file as shown below.

CONFIG += mobility
MOBILITY += systeminfo

[edit] 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;
};

[edit] 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.
131 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.

×