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. QProcess with no program to run
Forum Updated to NodeBB v4.3 + New Features

QProcess with no program to run

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 1.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.
  • JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #1

    Over in https://forum.qt.io/topic/118956/qprocess-runs-correctly-in-debug-but-in-release-mode-it-doesn-t-run-correctly the OP's code reads:

    QProcess *inputList= new QProcess(this);
    inputList-> start();
    inputList->write("xinput list");
    inputList->write("\n");
    inputList->closeWriteChannel();
    
    ui-> text Edit->insertPlainTextEdit( inputList-> readAllStandardOutPut());
    

    to which I replied in https://forum.qt.io/topic/118956/qprocess-runs-correctly-in-debug-but-in-release-mode-it-doesn-t-run-correctly/7 essentially saying:

    QProcess *inputList= new QProcess(this);

    inputList-> start();

    I seem to be the only person commenting on this, but what does this do?

    Since nobody commented and the OP seems happy, could someone explain what this does/how this works and, most importantly, where this is documented against QProcess, please?

    J.HilkJ T 2 Replies Last reply
    1
    • JonBJ JonB

      Over in https://forum.qt.io/topic/118956/qprocess-runs-correctly-in-debug-but-in-release-mode-it-doesn-t-run-correctly the OP's code reads:

      QProcess *inputList= new QProcess(this);
      inputList-> start();
      inputList->write("xinput list");
      inputList->write("\n");
      inputList->closeWriteChannel();
      
      ui-> text Edit->insertPlainTextEdit( inputList-> readAllStandardOutPut());
      

      to which I replied in https://forum.qt.io/topic/118956/qprocess-runs-correctly-in-debug-but-in-release-mode-it-doesn-t-run-correctly/7 essentially saying:

      QProcess *inputList= new QProcess(this);

      inputList-> start();

      I seem to be the only person commenting on this, but what does this do?

      Since nobody commented and the OP seems happy, could someone explain what this does/how this works and, most importantly, where this is documented against QProcess, please?

      T Offline
      T Offline
      TahmDev
      wrote on last edited by
      #7

      @JonB hey jonB, sorry for my late reply.
      Problem with the code I sent was that I typed it through my cellphone, therefore I missed a line before start to setProgram("/bin/bash")
      And for the xinput list...in linux terminal it returns the list of all the input devices connected to the system.

      JonBJ 1 Reply Last reply
      0
      • B Offline
        B Offline
        Bonnie
        wrote on last edited by
        #2

        I didn't comment in that post but I was thinking "this will simply cause a FailedToStart error".

        1 Reply Last reply
        0
        • JonBJ JonB

          Over in https://forum.qt.io/topic/118956/qprocess-runs-correctly-in-debug-but-in-release-mode-it-doesn-t-run-correctly the OP's code reads:

          QProcess *inputList= new QProcess(this);
          inputList-> start();
          inputList->write("xinput list");
          inputList->write("\n");
          inputList->closeWriteChannel();
          
          ui-> text Edit->insertPlainTextEdit( inputList-> readAllStandardOutPut());
          

          to which I replied in https://forum.qt.io/topic/118956/qprocess-runs-correctly-in-debug-but-in-release-mode-it-doesn-t-run-correctly/7 essentially saying:

          QProcess *inputList= new QProcess(this);

          inputList-> start();

          I seem to be the only person commenting on this, but what does this do?

          Since nobody commented and the OP seems happy, could someone explain what this does/how this works and, most importantly, where this is documented against QProcess, please?

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #3

          @JonB I assume the relevant documentation part is this one:

          fb09012d-a5c3-4244-a45b-ddbbe9457794-image.png

          https://doc.qt.io/qt-5/qprocess.html#details

          hidden, but it's there 🤷‍♂️


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          JonBJ 1 Reply Last reply
          1
          • J.HilkJ J.Hilk

            @JonB I assume the relevant documentation part is this one:

            fb09012d-a5c3-4244-a45b-ddbbe9457794-image.png

            https://doc.qt.io/qt-5/qprocess.html#details

            hidden, but it's there 🤷‍♂️

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @J-Hilk
            No, I do not understand! I have read that, and am well aware that you can use read/write to communicate with a running process. I believe that is all that section is saying(?). That is not the case here! There is no process specified to run as argument to QProcess::start() here. So what process is this writing to?? It appears that something is going to do something like: read whatever arrives, terminated by a \n, and then do something in the way of "executing" what was sent (xinput list\n in this case). I take it that is what the OP is claiming happens??

            Where in the world is anything like this explained anywhere, if that is the case??

            1 Reply Last reply
            0
            • J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by J.Hilk
              #5

              @JonB said in QProcess with no program to run:

              https://forum.qt.io/topic/118956/qprocess-runs-correctly-in-debug-but-in-release-mode-it-doesn-t-run-correctly

              the post in the other thread, the OP does no error checking, if you did, he would get a failed to start error due to the missing program.

              That said, why should a call to the underlying QIODevice crash or otherwise behave out of order ?
              It should return -1 as, the writing will fail, but thats about it.

              3d29a8eb-9634-4c6d-8faa-742b19a224e1-image.png


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              JonBJ 1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @JonB said in QProcess with no program to run:

                https://forum.qt.io/topic/118956/qprocess-runs-correctly-in-debug-but-in-release-mode-it-doesn-t-run-correctly

                the post in the other thread, the OP does no error checking, if you did, he would get a failed to start error due to the missing program.

                That said, why should a call to the underlying QIODevice crash or otherwise behave out of order ?
                It should return -1 as, the writing will fail, but thats about it.

                3d29a8eb-9634-4c6d-8faa-742b19a224e1-image.png

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #6

                @J-Hilk
                OK, so now you seem to be agreeing with my comment that you cannot go process->start(this)m like he does? It is not going to execute the xinput list\n he shows? Yet he seems happy with that and claims all is working?? That is what I am trying to understand here?

                I see only two overloads:

                void QProcess::start(const QString &program, const QStringList &arguments, QIODevice::OpenMode mode = ReadWrite)
                void QProcess::start(QIODevice::OpenMode mode = ReadWrite)
                

                So his inputList-> start() can only match the second one. How does that OP's comment "But when I run the inputattach in my qt in debug mode, it works properly and when I run "xinput list" it shows me the added device but in relaese mode it doesn't work " work? I don't see this will ever "run" xinput list, which is why I commented as I did, that is what I'm trying to understand? I thought I knew all there is to know about QProcess, this has thrown me :) If he had written "I got rid of that part of the code" then I would have no problem....!

                J.HilkJ 1 Reply Last reply
                0
                • JonBJ JonB

                  Over in https://forum.qt.io/topic/118956/qprocess-runs-correctly-in-debug-but-in-release-mode-it-doesn-t-run-correctly the OP's code reads:

                  QProcess *inputList= new QProcess(this);
                  inputList-> start();
                  inputList->write("xinput list");
                  inputList->write("\n");
                  inputList->closeWriteChannel();
                  
                  ui-> text Edit->insertPlainTextEdit( inputList-> readAllStandardOutPut());
                  

                  to which I replied in https://forum.qt.io/topic/118956/qprocess-runs-correctly-in-debug-but-in-release-mode-it-doesn-t-run-correctly/7 essentially saying:

                  QProcess *inputList= new QProcess(this);

                  inputList-> start();

                  I seem to be the only person commenting on this, but what does this do?

                  Since nobody commented and the OP seems happy, could someone explain what this does/how this works and, most importantly, where this is documented against QProcess, please?

                  T Offline
                  T Offline
                  TahmDev
                  wrote on last edited by
                  #7

                  @JonB hey jonB, sorry for my late reply.
                  Problem with the code I sent was that I typed it through my cellphone, therefore I missed a line before start to setProgram("/bin/bash")
                  And for the xinput list...in linux terminal it returns the list of all the input devices connected to the system.

                  JonBJ 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @J-Hilk
                    OK, so now you seem to be agreeing with my comment that you cannot go process->start(this)m like he does? It is not going to execute the xinput list\n he shows? Yet he seems happy with that and claims all is working?? That is what I am trying to understand here?

                    I see only two overloads:

                    void QProcess::start(const QString &program, const QStringList &arguments, QIODevice::OpenMode mode = ReadWrite)
                    void QProcess::start(QIODevice::OpenMode mode = ReadWrite)
                    

                    So his inputList-> start() can only match the second one. How does that OP's comment "But when I run the inputattach in my qt in debug mode, it works properly and when I run "xinput list" it shows me the added device but in relaese mode it doesn't work " work? I don't see this will ever "run" xinput list, which is why I commented as I did, that is what I'm trying to understand? I thought I knew all there is to know about QProcess, this has thrown me :) If he had written "I got rid of that part of the code" then I would have no problem....!

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #8

                    @JonB the OP did not copy and past, because this line shouldn't compile

                    ui-> text Edit->insertPlainTextEdit( inputList-> readAllStandardOutPut());
                    
                    

                    So I assume there's stuff missing.


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    1
                    • T TahmDev

                      @JonB hey jonB, sorry for my late reply.
                      Problem with the code I sent was that I typed it through my cellphone, therefore I missed a line before start to setProgram("/bin/bash")
                      And for the xinput list...in linux terminal it returns the list of all the input devices connected to the system.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #9

                      @TahmDev said in QProcess with no program to run:

                      And for the xinput list...in linux terminal it returns the list of all the input devices connected to the system.

                      Yes, I realize this :)

                      Problem with the code I sent was that I typed it through my cellphone, therefore I missed a line before start to setProgram("/bin/bash")

                      Ah ha! OK, now at least make some sense to me :) For that you would have been better/simpler to use the -c argument for one command:

                      process->start("/bin/bash", QStringList() << "-c" << "xinput list");
                      // or in this case just
                      process->start("xinput", QStringList() << "list");
                      

                      but at least I understand what is going on now! :)

                      T 1 Reply Last reply
                      1
                      • JonBJ JonB

                        @TahmDev said in QProcess with no program to run:

                        And for the xinput list...in linux terminal it returns the list of all the input devices connected to the system.

                        Yes, I realize this :)

                        Problem with the code I sent was that I typed it through my cellphone, therefore I missed a line before start to setProgram("/bin/bash")

                        Ah ha! OK, now at least make some sense to me :) For that you would have been better/simpler to use the -c argument for one command:

                        process->start("/bin/bash", QStringList() << "-c" << "xinput list");
                        // or in this case just
                        process->start("xinput", QStringList() << "list");
                        

                        but at least I understand what is going on now! :)

                        T Offline
                        T Offline
                        TahmDev
                        wrote on last edited by
                        #10

                        @JonB yeah actually I knew it... But it was sooo frustrating for me...K was trying so hard to make my app work and it wasn't therefore I tried soo many different paths and commands😁

                        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