Unsolved problem in run external program with QProcess
-
@JonB thanks, so this time i remove
waitFor...()
from my code and only use signal and slot, this time Finished Signal emited, with0 QProcess::NormalExit
, but i get unknow error too -
@saeid0034
Better :) Don't usewaitFor...()
s again :) "unknown error" can also maybe if no error. Put in slots onreadyReadStandardOutput()
/Error()
now? -
@JonB both give me empty output
BigPAKC->readAllStandardOutput(); BigPAKC->readAllStandardError();
-
@saeid0034
I already suggested you trycmd /c dir
but you would not. So far as I can see everything is working fine, you have not shown there is any actual problem.You don't show code, so I can only hope your code is correctly in slots set up in the right places.
-
@JonB thanks, yes code seems working
i send my code above, it all code i use for qprocess.
and about cmd /c dir, what i'm supposed to do with it? -
@saeid0034 said in problem in run external program with QProcess:
thanks, yes code seems working
If you mean everything is working then there is no issue,
i send my code above, it all code i use for qprocess.
You have shown fragments of code, which you say you have added to and deleted from. I do not know what your code looks like now.
and about cmd /c dir, what i'm supposed to do with it?
You were supposed to replace your process
start()
ing code by:
BigPAKC->start("cmd", QStringList() << "/c" << "dir");
EDIT
OMG, I have only just noticed in your code:if (!BigPAKC->waitForStarted()) qDebug() << "started"; if (!BigPAKC->waitForFinished(-1)) qDebug() << "Finished";
I did not see the
!
s. So you print nothing when all is well.... So what is your problem if it all worked fine from the outset? -
@JonB Im worried about
Unknown error
but as you say its possible its mean no error -
QProcess::UnknownError
5 An unknown error occurred. This is the default return value oferror()
.No error occurred in your code. This has been a long discussion for that situation.
Why in the world did you write
if (!BigPAKC->waitForStarted()) qDebug() << "started";
instead of
if (BigPAKC->waitForStarted())
? -
@JonB because i see example on https://doc.qt.io/qt-5/qprocess.html
-
@saeid0034
Your code:if (!BigPAKC->waitForStarted()) qDebug() << "started"; if (!BigPAKC->waitForFinished(-1)) qDebug() << "Finished";
Your description of what was wrong:
but my problem is both waitForStarted and waitForFinished never work, i mean waitForFinished doesnt wait for process to end and print Finished at start,
Why do you expect a successful
waitForFinished()
to printFinished
here? Do you understand that with your use of!
it won't say anything when everything succeeds as it should? -
@JonB sorry about that, i only see unknow error -_-
thanks about help