Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-101275

Unable to capture output from QProcess

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 6.2.3
    • Core: Other
    • Linux/X11

       

      Running bash commands on Linux with QProcess in 6.2 does not work the same as with 5.15. Previously, running shell commands ran and captured the output. Now it only runs, but does not capture output.

      The following code is adapted from the Qt 6 QProcess documentation for running a synchronous process.

      QString output;
      QProcess *process = new QProcess();
      /* testing QProcess documentation synchronous example */
      process->start("sh", QStringList() << "-c" << s);
      if (!process->waitForStarted())
          output = "QProcess failed to start, with error [" + process->errorString() + "]"; if (!process->waitForFinished())
          output = "QProcess failed to finish, with error [" + process->errorString() + "]";
      output = QString(process->readAll());
      delete process;

      The expected behavior is that readAll() returns any output from stdout and stderr, but the actual behavior is that it returns nothing.

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            thiago Thiago Macieira
            gregb Gregory
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes