I'm facing a weird problem with Qt5 and C++ on windows 10.
I have to run a QProcess and detect its output, but it prints only with some commands (actually just one):
with the ping
command, it prints the output normally:
process->start("ping 8.8.8.8");
process->waitForFinished();
std::cout << process->readAllStandardOutput();
but with echo
it doesn't print anything:
process->start("echo foo")
I tried changing the command (like dir
) but it doesn't work; playing with (") or (') doesn't work either.
After some research I found that the command failed to start. Why is that?
I had to run the process with:
cmd /c
So the final result is:
process->start("cmd /c \"echo foo\" ");