PDA

View Full Version : QProcess timeout



MonkeyJLuffy
22nd April 2010, 09:58
Hy everybody

I have a litlle problem, I would like to lauch an extern scrip using QProcess, and I would like to have a timeout.

But I couldn't use the waitForTimeout() methode, I need to use the Signal/slot.

My question is, if it have a possibility to set a timeout to the QProcess without using the method waitForTimeout() ?

Thank's

:confused:

nikhilqt
22nd April 2010, 10:15
Check out the SIGNLAS of QProcess. There is a signal called finished(...) (http://doc.trolltech.com/4.6/qprocess.html#finished) where you can get the exitcode and QProcess::ExitStatus too.

MonkeyJLuffy
22nd April 2010, 10:25
Yes i have readed it, but i would like to put a timeout to my process, different to the default timeout of QProcess. Then, when this timeout occure, QProcess send me the signal finished.

But the main problem is how to change the default timeout of QProcess without using waitForTimedout() ?

Lesiok
22nd April 2010, 10:38
And how about waitForFinished (http://doc.trolltech.com/4.6/qprocess.html#waitForFinished) ?

MonkeyJLuffy
22nd April 2010, 11:00
No, I couldn't use any method waitFor...

No have possibility ?:confused:

Lesiok
22nd April 2010, 11:08
What mean "I couldn't use any method waitFor..." ? Why ?
PS.
I think that You must use extra QTimer to generate timeout.

MonkeyJLuffy
22nd April 2010, 11:13
It mean that the restriction of this program no let me use any "wait" that suspend the program

The timeout that i want is 300'000 ms and the default is 30'000, then the QTimer don't resolve my problem

Any other solucion ?

wysota
22nd April 2010, 12:28
Create a QTimer, connect its timeout() signal to some slot and when the slot fires you will know the process timed out and you can kill it. If you receive the finished() signal before the timer times out you can stop the timer.

Lesiok
22nd April 2010, 12:42
About what timeout You are talking ?
Just do like Wysota and me suggest.