QProcess Wrong Behavior

124 views Asked by At

My application runs different bash files when i run my application under QTCreator everything works fine but when i run my application directly i cant read the QProcess output . even when i run my application via Terminal it works fine , so where is the problem ?
i'm using QT 5.7 / OSX Platform
here is my code

        QProcess proc ;
    proc.start(QCoreApplication::applicationDirPath() + "/check.sh");
    proc.waitForFinished();
    QString output = QString(proc.readAll());
    qDebug() << output ;
1

There are 1 answers

3
Swift - Friday Pie On BEST ANSWER

There are some possibilities you should investigate

  • Can you confirm that scripts are running though when you run it standalone?
  • QProcess always was a little skittish about creating processes when supplied scripts, depending on platform. Does script have shebang in it? Does it match the shell you're running your program from? You may need to create process based on shell, supplying script's file name as a parameter.
  • QProcess::readAll() May return nothing if output buffer wasn't flushed by the process. Outputting EOL at end would force the flush.