PDA

View Full Version : Get contents from output of console app



madawg
26th September 2018, 10:09
I am writing a console app.
The console print a few line. And then, I want to get the last line of content output.
How to do that?
Example:
I want to check if the last line contains: "Processing", the console app delete this line and changed "Done"

d_stranz
26th September 2018, 18:07
If you are writing the app, then you are in control of what is written to the console. Why would you need to capture the console output before it is printed and then change it? Just print what should be there.

Ginsengelf
27th September 2018, 09:40
Hi, if you want to replace the last line you can use "\r" to go to the beginning of the line before printing something else.
If you really need to know what you printed last time then store it in a variable. Although I concur with d_stranz: just print the correct line.

Ginsengelf

madawg
27th September 2018, 13:19
I also need get content of console output
I have two way to print:
qDebug() << "Content";
QTextStream out(stdout); out <<"Content";
Which solution is the best for this?

Ginsengelf
27th September 2018, 16:36
Hi, qDebug won't be visible in release builds, so use the second option.

Ginsengelf