View Full Version : Reading standard error from a process
harden
26th July 2011, 11:58
Hello Qt developers! I have the following problem, hope you'll be able to help me.
From my Qt app I run a QProcess - an application, which normally prints some messages to a console screen. I want to capture these messages in my app using readAllStandardError(), but it gives no result. It eventually appears, but only after i call terminate() on a QProcess, when cumulated messages appear at once.
What should I do to see the messages just as they are printed?
stampede
26th July 2011, 12:04
an application, which normally prints some messages to a console screen.
Probably messages are buffered, try to flush the std error output in this application ( fflush(stderr), this was posted few times on the forum ).
cincirin
26th July 2011, 12:09
And if you want to capture real-time messages, connect your slot to QProcess::readyReadStandardError.
harden
26th July 2011, 12:28
The problem is that I can't change anything in the message sender application (It's not my application), I can only manipulate the Qt application (my aplication, receiver of messages).
So I need something like QProcess::flush()...
stampede
26th July 2011, 13:27
You may try to pass QIODevice::Unbuffered flag when starting the process. I don't know if it works, never tried that.
CroOm
26th July 2011, 14:51
instead of showing the messages in the console screen pass them to a file or data array and print them to the console afterwards, u can access the file or data array anytime.
on the other hand , if your data is stored but not shown try to insert:
QApplication::processEvents() ;
based on how often errors are shown
harden
26th July 2011, 16:14
You may try to pass QIODevice::Unbuffered flag when starting the process. I don't know if it works, never tried that.
Doesn't work in this case.
Anyway, thanks for all the replies!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.