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. How to get the text output from an ui program with the qprocess

How to get the text output from an ui program with the qprocess

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 353 Views 2 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.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by nicker player
    #1

    I used the qprocess to start an external program which is an ui program.how to send the messages from the ui program to the qprocess executions?

    //project a:
    int main(){
    qDebug()<<"output";
    }
    
    //project b:
    int main(){
        qprocess pr;
        pr.called(a.exe);
        while(){
        // how to get the output from the project a?
       }
    }
    
    Pl45m4P JonBJ 2 Replies Last reply
    0
    • nicker playerN nicker player

      I used the qprocess to start an external program which is an ui program.how to send the messages from the ui program to the qprocess executions?

      //project a:
      int main(){
      qDebug()<<"output";
      }
      
      //project b:
      int main(){
          qprocess pr;
          pr.called(a.exe);
          while(){
          // how to get the output from the project a?
         }
      }
      
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @nicker-player

      You can read the std out of QProcess for example with

      • https://doc.qt.io/qt-6/qprocess.html#readyReadStandardOutput
      • https://doc.qt.io/qt-6/qprocess.html#readAllStandardOutput

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      1
      • nicker playerN nicker player

        I used the qprocess to start an external program which is an ui program.how to send the messages from the ui program to the qprocess executions?

        //project a:
        int main(){
        qDebug()<<"output";
        }
        
        //project b:
        int main(){
            qprocess pr;
            pr.called(a.exe);
            while(){
            // how to get the output from the project a?
           }
        }
        
        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by
        #3

        @nicker-player
        Please read the QProcess documentation. You will see readAllStandardError/Output(), which can be used to read anything the child process writes on stdout/err.

        You will also need to write a properly constructed Qt program. There will be no while loop. Either use waitForFinished() or enter the Qt event loop and use the readyRead... signals.

        NOTE: Whether what you call "an ui program" will actually write anything at all to stdout/err is a different matter. Command line program often do, but UI ones may not if all they do is present a UI to the user.

        Pl45m4P 1 Reply Last reply
        2
        • JonBJ JonB

          @nicker-player
          Please read the QProcess documentation. You will see readAllStandardError/Output(), which can be used to read anything the child process writes on stdout/err.

          You will also need to write a properly constructed Qt program. There will be no while loop. Either use waitForFinished() or enter the Qt event loop and use the readyRead... signals.

          NOTE: Whether what you call "an ui program" will actually write anything at all to stdout/err is a different matter. Command line program often do, but UI ones may not if all they do is present a UI to the user.

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @JonB said in How to get the text output from an ui program with the qprocess:

          NOTE: Whether what you call "an ui program" will actually write anything at all to stdout/err is a different matter.

          I assumed that project "a" (the one running as QProcess) is @nicker-player 's own additional Qt GUI app :)

          //project a:
          int main(){
          qDebug()<<"output";
          }
          

          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          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