Problem using stdout in QProcess
-
I am a new in QT. need to catch the output from the process which I started.
What I am doing wrong?Thank you.
@ QString program = "echo";
QStringList arguments;
arguments << "test >/dev/stdout";QProcess *myProcess = new QProcess(this); myProcess->start(program, arguments); myProcess->setReadChannel( QProcess::StandardOutput ); char buff[1024]; qint64 len = myProcess->readLine( buff, qint64(1024)); int len = myProcess->readLine( buff, qint64(1024)); printf(" buffer %s %d \n", buff, int(len));@
get nothing as result
-
[quote author="Tomma" date="1300440105"]Or just waitForFinished() after start().
Tricky part might be getting those arguments right[/quote]
I recommend against using the waitFor* methods in Qt if you can avoid them at all, especially if you are building GUI applications. -
[quote author="Andre" date="1300440589"]I recommend against using the waitFor* methods in Qt if you can avoid them at all, especially if you are building GUI applications.
[/quote]Let's say it that way:
If you are building command line apps with have to wait, waitFor* makes sense.
If you build Gui, use signals. -
I agree with Gerolf. This way must work for you.
-
All, thank you very much. I am out of the office now, will test this soon. Sure it works.