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 debug a QProcess output
Forum Update on Monday, May 27th 2025

How to debug a QProcess output

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 1.9k Views
  • 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.
  • N Offline
    N Offline
    N1coc4colA
    wrote on last edited by
    #1

    Hello,
    I'm working on a personnal project and I'm missing some features (that I'll implement).
    Now, I'm looking on how to get the output of a QProcess AT RUNTIME of it. Before, I used startDetached and the app debuged (by it self) what it wants, but I want to capture some values (%) that are printed in terminal (the output) but I searched a long, very long time and I haven't found how to.
    Can someone help me to have a solution?
    @n1coc4cola

    jsulmJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      If you want to read from Process' stdout/stderr don't start as detached.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • N N1coc4colA

        Hello,
        I'm working on a personnal project and I'm missing some features (that I'll implement).
        Now, I'm looking on how to get the output of a QProcess AT RUNTIME of it. Before, I used startDetached and the app debuged (by it self) what it wants, but I want to capture some values (%) that are printed in terminal (the output) but I searched a long, very long time and I haven't found how to.
        Can someone help me to have a solution?
        @n1coc4cola

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @N1coc4colA said in How to debug a QProcess output:

        but I searched a long, very long time and I haven't found how to

        What about:

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

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        3
        • N Offline
          N Offline
          N1coc4colA
          wrote on last edited by
          #4

          yes but it don't work DURING the QProcess RUNTIME, in what I experimented for the moment...
          I have try by using connect with readyRead() and readyReadStandardOutput() signals to a readAllStandardOutput() but the signal is not emited during the runtime, I have to use the waitForReadyRead(). Or should I use the readLine() function from QIODevice? readAll()?

          jsulmJ 1 Reply Last reply
          0
          • N N1coc4colA

            yes but it don't work DURING the QProcess RUNTIME, in what I experimented for the moment...
            I have try by using connect with readyRead() and readyReadStandardOutput() signals to a readAllStandardOutput() but the signal is not emited during the runtime, I have to use the waitForReadyRead(). Or should I use the readLine() function from QIODevice? readAll()?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @N1coc4colA Did you read what @Christian-Ehrlicher wrote? Do NOT start the process detached.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            3
            • N Offline
              N Offline
              N1coc4colA
              wrote on last edited by
              #6

              Yes, but it debugs the first line and I have to do:

              process.start(command4);
              qDebug() << process.readAllStandardOutput();

              and else, I need a loop and the loop blocks my program. Else, I connected readRead() and readyReadStandardOutput() but is not emited. Now I switched, my apps uses Github and it have an API. So I use a URL, replace the content by the user's one, get the .zip file (of when you click on download as a .zip) and write it on the disk.

              jsulmJ aha_1980A 2 Replies Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @N1coc4colA said in How to debug a QProcess output:

                and else, I need a loop and the loop blocks my program

                Please read the Signal/Slots documentation and take a look at e.g. the signals of QProcess - there is no need to block anything.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                4
                • N N1coc4colA

                  Yes, but it debugs the first line and I have to do:

                  process.start(command4);
                  qDebug() << process.readAllStandardOutput();

                  and else, I need a loop and the loop blocks my program. Else, I connected readRead() and readyReadStandardOutput() but is not emited. Now I switched, my apps uses Github and it have an API. So I use a URL, replace the content by the user's one, get the .zip file (of when you click on download as a .zip) and write it on the disk.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @N1coc4colA said in How to debug a QProcess output:

                  process.start(command4);
                  qDebug() << process.readAllStandardOutput();

                  This can't work! You need to read when there is actually something to read, so do what @Christian-Ehrlicher suggested...

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2
                  • N N1coc4colA

                    Yes, but it debugs the first line and I have to do:

                    process.start(command4);
                    qDebug() << process.readAllStandardOutput();

                    and else, I need a loop and the loop blocks my program. Else, I connected readRead() and readyReadStandardOutput() but is not emited. Now I switched, my apps uses Github and it have an API. So I use a URL, replace the content by the user's one, get the .zip file (of when you click on download as a .zip) and write it on the disk.

                    aha_1980A Offline
                    aha_1980A Offline
                    aha_1980
                    Lifetime Qt Champion
                    wrote on last edited by aha_1980
                    #9

                    Hi @N1coc4colA,

                    You might want to have a look at this example.

                    Regards

                    Qt has to stay free or it will die.

                    1 Reply Last reply
                    1

                    • Login

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