Unsolved Wrong QProcess Behavior
-
hi , i'm new to QT
i have an application with runs some simple bash files .
now when i run the application from the QTCreator everything works fine and i can read the QProcess output but when i open application directly i can't read the QProcess output and output is always "" .
here is my code :QProcess proc ; proc.start(QCoreApplication::applicationDirPath() + "/check.sh"); proc.waitForFinished(); QString output = QString(proc.readAll()); qDebug() << output ;
i'm using QT 5.7 on OSX Platform
note :
*** when i run my application via terminal it works fine *** -
use readAllStandardOutput() to read the output
-
Try
/* proc.waitForFinished(-1);*/
the above line wait untill the process gets finished.Refer this link
http://doc.qt.io/qt-5/qprocess.html#waitForFinished -
@karti-gesar said in Wrong QProcess Behavior:
use readAllStandardOutput() to read the output
Hi,
Yes, and usereadAllStandardError()
to get the error messages.
Maybe the program did not run because of a wrong path.
-Michael. -
ok when i run the application directly QCoreApplication::applicationDirPath() returns / as the dir but when i run the app via terminal it's the real application path !! is it a bug ?!
-
Hi,
How exactly are you calling your application ?
Are you building an app bundle ?