×
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 (Text replace - "Category:MeeGo" to "Category:MeeGo Harmattan")
hamishwillee (Talk | contribs)
m (Hamishwillee - Add Abstract. Improve categories)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
[[Category:Qt]][[Category:Qt Mobility]][[Category:Code Snippet]][[Category:Code Snippet]][[Category:MeeGo Harmattan]][[Category:Symbian]][[Category:UI]]
+
[[Category:Qt]][[Category:Qt Mobility]][[Category:MeeGo Harmattan]][[Category:Symbian]][[Category:UI]][[Category:Base/System]][[Category:Code Snippet]][[Category:Symbian^3]][[Category:Nokia Belle]]
 +
{{Abstract|This snippet shows how to prevent the screen saver from activating in an application by using Qt Mobility's {{Icode|QSystemScreenSaver}} class.}}
 +
 
 
{{ArticleMetaData <!-- v1.2 -->
 
{{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]]) -->
Line 22: Line 24:
 
|author= [[User:Kratsan]]
 
|author= [[User:Kratsan]]
 
<!-- The following are not in current metadata -->
 
<!-- The following are not in current metadata -->
|subcategory= Qt Mobility
 
 
|id= CS001657
 
|id= CS001657
 
}}
 
}}
 
==Overview==
 
 
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 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 46: Line 43:
 
Add the inclusion of {{Icode|<QSystemScreenSaver>}}.
 
Add the inclusion of {{Icode|<QSystemScreenSaver>}}.
  
<code cpp>
+
<code cpp-qt>
 
#include <QSystemScreenSaver>
 
#include <QSystemScreenSaver>
 
</code>
 
</code>
Line 52: Line 49:
 
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.
 
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
 
{
 
{

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.
122 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.

×