Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] QProcess and backlight linux command
Forum Updated to NodeBB v4.3 + New Features

[Solved] QProcess and backlight linux command

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 5.2k 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.
  • M Offline
    M Offline
    Memphis
    wrote on last edited by
    #1

    Hello Guys!
    I try to modify the brightness of my display in Qt, running the command:

    echo 6 > /sys/class/backlight/mxs-bl/brightness

    and using QProcess like this:

    @QProcess *sh = new QProcess();
    sh->start( "echo 6 > /sys/class/backlight/mxs-bl/brightness");
    sh->waitForFinished();
    QByteArray output = sh->readAll();
    ui->label->setText(output);
    sh->close();@

    But it print only "6 > /sys/class/backlight/mxs-bl/brightness" instead of do the command like in the shell, and don't change the value of the brightness.
    Any idea? Thank you so much.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      try this:
      @
      QProcess *sh = new QProcess();
      sh->write("6"); //write to stdin of the process
      //sh->closeWriteChannel(); //not sure if this line is needed
      sh->start( "/sys/class/backlight/mxs-bl/brightness");
      @

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Memphis
        wrote on last edited by
        #3

        It didn't work, :-( don't change anything

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          ok... one more try:
          @
          QProcess *sh = new QProcess();
          sh->start( "/sys/class/backlight/mxs-bl/brightness");
          sh->write("6"); //write to stdin of the process
          sh->closeWriteChannel();
          @

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Memphis
            wrote on last edited by
            #5

            nothing to do, still does not do anything, but excuse me I should not include the echo command? is not recognized ">" sign on Qt

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tomma
              wrote on last edited by
              #6

              Why are you trying to use QProcess to write to file?
              Wouldn't it be easier to use QFile?

              @
              QFile f("/sys/class/backlight/mxs-bl/brightness");
              f.open(QIODevice::WriteOnly | QIODevice::Truncate);
              f.write("6");
              @

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Memphis
                wrote on last edited by
                #7

                Thank you it works ;-)

                1 Reply Last reply
                0
                • raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #8

                  well ... i thought "/sys/class/backlight/mxs-bl/brightness" is a application rather than a file.
                  I thought you know what your were doing when you using QProcess in the first place ;)

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  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