Hello )
When start console program using QProcess's start() function, this program is invisible (no window). Is it possible to start it in window but have control on it by means of QProcess (start/stop, view status etc)?
Hello )
When start console program using QProcess's start() function, this program is invisible (no window). Is it possible to start it in window but have control on it by means of QProcess (start/stop, view status etc)?
You'd have to open a terminal program (like xterm) from QProcess and ask it to run the application you wish to control. But it might be easier if you dedicate a text edit widget where you will just display the output of the application.
Unfortunatelly its not always possible to catch console program output - it is often buffered and not available.
xterm works, and hope on all *nix platforms, including Mac?
But do you know similar workaround in windows ?
What do you mean by buffered? If it's buffered, you won't see it in the terminal as well... So using xterm (or not) wouldn't change a thing.
for example, such code:will not output anything to QProcess until console program endQt Code:
puts("Some strings.."); gets(s); puts(s); ...To copy to clipboard, switch view to plain text mode
But if you addbefore these strings, it will work.Qt Code:
setvbuf(stdout,NULL,0,_IOFBF);To copy to clipboard, switch view to plain text mode
Have you heard about a function called fflush()?
where can i use this function? console programs i told about aren't my and i can't do anything with its code.
as i understand, QProcess is implemented so that it never show console program window - and i wonder why it isn't an option.. so i need to invent various workarounds. very strange imho.
it's your?
http://prog.org.ru/forum/topic_5677_...ed38e6971.html
i have try
after puts(s); -- and all work right;
so problem to call flush in your class -- maybe start timer after myProc.write() with little delay
check this
Qt Code:
To copy to clipboard, switch view to plain text mode
Well, it seems i need to specify some details:
Suppose i have console program (worked in text mode), without any source - only executable (so i cant change anything in this program, like put fflush() somewhere in it), which periodically outputs some info to the screen (for example, gets it from network), and allows me to input some "commands" which it then "process" and shows me result. To stop this program i need to enter "quit" command.
I want to start several such programs from one Qt application and have ability to check running status and stop/restart them if necessay. And also it would be very desirable to get access to program console.
But if i do that with QProcess start() method, i cant get program window, cant view program output and cant input anything (well, may be can - but dont see it).
If i use startDetached() - i get program window, but lose control at it from my Qt application.
Any ideas?
evgenM: closeWriteChannel() works in my simple example (just stop it), but doesnt work in other cases
i realy not understand the problem - u do right all u must do - problem only in this bugged console app (no flush) - i am not sure u can fix it in YOUR app. So u have one way - ask author to correct.
Bookmarks