PDA

View Full Version : Interactive QProcess



inktomi
7th August 2009, 01:41
I'm trying to execute a process using QProcess. This process performs its job until it is interrupted by pressing the 'q' key.

I was trying to simulate pressing the 'q' key by sending the character to the process via the write() function. That did not work.

Then I found this Qt Labs blog post (http://labs.trolltech.com/blogs/2006/03/16/starting-interactive-processes-with-qprocess/) which I think is trying to achieve what I want. The problem is, I can't understand what the guy is doing especially the meaning of dup and dup2.

I would be very grateful if someone could explain.

Thank You

wagmare
7th August 2009, 06:12
one question .. out of scope but ...
if u press key "q" the QProcess application is closing or complete a task but not killed ..
if the external application be killed when user press "q" ... then u can use keyPressEvent , catch the key "q" and close the process QProcess::terminate() ..

inktomi
7th August 2009, 08:20
one question .. out of scope but ...
if u press key "q" the QProcess application is closing or complete a task but not killed ..
if the external application be killed when user press "q" ... then u can use keyPressEvent , catch the key "q" and close the process QProcess::terminate() ..

That does kill the application (that's what I was doing). However when the 'q' is pressed, apart from terminating, it does some other important stuff before quitting.

inktomi
8th August 2009, 18:21
Update:

I was using kill() to kill the application; terminate() does nothing.

When the application stops and waits for user input I can use write() to send input, and that does work.

What does not work is when I send input while the application is working.