Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Control screen luminosity
Forum Updated to NodeBB v4.3 + New Features

Control screen luminosity

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 3 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zulu_x26
    wrote on last edited by
    #1

    I have an application which scrolls automatically some data in a listview, without user action. After about 30 seconds the screen luminosity goes at half value and after another 30 seconds the screen goes off. I'd like to be able to prevent this from the application. From what I searched so far it seems it has to do with the screensaver, but Qt5.3 (that I am using) has no suport for controlling the screensaver.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Gennon
      wrote on last edited by
      #2

      What kind of device is this? Android, iOS, some other embedded device?

      If you can set the power settings on the screen to stay awake at all times, then I think you can fix it. On android at least you can prevent the screen to sleep. On embedded devices you write your own driver to do this or just set some settings on existing driver.

      However, this is not related to QtQuick.

      /Gen

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zulu_x26
        wrote on last edited by
        #3

        It's an Android phone. My problem is I don't want to alter the power settings from the phone settings menu, I would like to do it from the app, so I can stop power saving when the app starts and restore it before the app closes.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Gennon
          wrote on last edited by
          #4

          Ok, then you should take a look at this:

          Permission you need to change power settings:
          http://developer.android.com/reference/android/Manifest.permission.html#WAKE_LOCK

          Java method to change power settings:
          http://developer.android.com/reference/android/os/PowerManager.WakeLock.html

          Example of using C++ to access Java in a Qt application:
          http://doc-snapshot.qt-project.org/qt5-5.3/qtandroidextras-notification-example.html

          /Gen

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zulu_x26
            wrote on last edited by
            #5

            Thank you very much, I'll give it a try.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              danielvaz
              wrote on last edited by
              #6

              Try to add this new method on example qtandroidextras-notification-example in the file NotificationClient.java

              @
              public static void keepScreenOn() {
              Window w = m_instance.getWindow();
              if ( w == null ) {
              Log.v(TAG, "null window");
              } else {
              w.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
              }
              }
              @

              Add these imports in the file NotificationClient.java
              @
              import android.view.WindowManager;
              import android.view.Window;
              import android.util.Log;
              @

              Call it in main.cpp just after QGuiApplication.
              @
              QAndroidJniObject::callStaticMethod<void>("org/qtproject/example/notification/NotificationClient",
              "keepScreenOn");@

              I tried to add it after line
              @QQuickView view;@

              and after line

              @view.show();@

              but it not works for me.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                danielvaz
                wrote on last edited by
                #7

                Try to add this new method on example qtandroidextras-notification-example in the file NotificationClient.java

                @
                public static void keepScreenOn() {
                Window w = m_instance.getWindow();
                if ( w == null ) {
                Log.v(TAG, "null window");
                } else {
                w.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                }
                }
                @

                Add these imports in the file NotificationClient.java
                @
                import android.view.WindowManager;
                import android.view.Window;
                import android.util.Log;
                @

                Call it in main.cpp just after QGuiApplication.
                @
                QAndroidJniObject::callStaticMethod<void>("org/qtproject/example/notification/NotificationClient",
                "keepScreenOn");@

                I tried to add it after line
                @QQuickView view;@

                and after line

                @view.show();@

                but it not works for me.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved