×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    55

    Disable Screensaver

    To disable the automatic screensaver lock-on and dim light:

    -I have to include QtMobility on the .pro file:

    CONFIG += mobility
    MOBILITY += systeminfo


    -Use QSystemScreenSaver->setScreenSaverInhibit():

    Code:
     #include <QSystemScreenSaver>
    
    QSystemScreenSaver *sss=new QSystemScreenSaver ( this );
    sss->setScreenSaverInhibit();
    My problem is I don't know if this code is right and where and how to include it. I was looking at the QtMobility examples but I cant figure out. Can anybody help me?
    Oscar B
    paniccode.com

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Disable Screensaver

    Hi,
    the code looks right.

    you can add that functionality to one of your classes like shown below

    #include <QObject>
    #include <QSystemScreenSaver>

    class myClass : public QObject
    {
    Q_OBJECT
    public:
    explicit myClass(QObject *parent = 0): sss(0){}

    void setScreenSaverInhibit(bool inhibit) ){
    if (inhibit) {
    if (sss) return;
    sss = new QSystemScreenSaver (this);
    sss->setScreenSaverInhibit();
    } else {
    delete sss;
    sss = 0;
    }
    }
    private:
    QSystemScreenSaver *sss

    };

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    55

    Re: Disable Screensaver

    Thanks for your answer. Im trying to figure out where do I have to include the code:

    at the main.cpp? at qmlapplicationviewer.h?

    Sorry but I have no clue.
    Oscar B
    paniccode.com

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    55

    Re: Disable Screensaver

    BTW,

    It seems it can be done from QML using QTMobility:

    http://doc.qt.nokia.com/qtmobility-1...reensaver.html

    But I cant make it work either.
    Oscar B
    paniccode.com

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    55

    Red face Re: Disable Screensaver

    Ok, I got it.

    To disable de screensaver using QtMobility:

    -Enable QtMobility on the .pro file:

    Code:
     CONFIG += mobility
     MOBILITY += systeminfo
    -Import QtMobility at the start of your main.qml file with this line:

    Code:
     import QtMobility.systeminfo 1.1
    -Add this element to your main.qml file:

    Code:
        ScreenSaver { id: screenSaver
            Component.onCompleted: {screenSaver.setScreenSaverDelayed(true) }
        }
    Oscar B
    paniccode.com

  6. #6
    Registered User
    Join Date
    May 2010
    Posts
    2

    Re: Disable Screensaver

    Hi Oscar,
    I have used that code but it does not dim the lights? Did your use dim the lights as well?
    Thanks,
    MJ

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    55

    Re: Disable Screensaver

    Quote Originally Posted by preeman View Post
    Hi Oscar,
    I have used that code but it does not dim the lights? Did your use dim the lights as well?
    Thanks,
    MJ
    What this code does is disable the screensaver and *avoid* the lights dim.
    Oscar B
    paniccode.com

  8. #8
    Registered User
    Join Date
    May 2010
    Posts
    2

    Re: Disable Screensaver

    ah ok, is there code that dims the lights as well? I have made a QML flip clock but I wanted an option for the user to leave it as a screen saver. If I use the code, screensaver is off, but the lights are still with big battery draw.

    The project is at http://bit.ly/j9p2A3
    Last edited by preeman; 2011-06-10 at 16:28. Reason: Adding link

Similar Threads

  1. Disable screensaver and backlight
    By Maysoon88 in forum Qt
    Replies: 1
    Last Post: 2010-11-29, 15:16
  2. Disable screensaver and backlight
    By Maysoon88 in forum [Archived] Qt Mobility Project
    Replies: 0
    Last Post: 2010-11-29, 12:38
  3. Nokia 6100 - Disable the screensaver?
    By h2ooo in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-17, 00:16
  4. disable screensaver in 3650
    By fahad_alolama in forum Symbian
    Replies: 1
    Last Post: 2003-11-23, 09:59

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •