PDA

View Full Version : Use of QTimer



A.H.M. Mahfuzur Rahman
6th August 2009, 15:06
Is there any way to call parameterized function with timeout(), making it a class or somehow?

wrdieter
6th August 2009, 17:53
If you want a particular object to handle the timeout, just connect the timeout signal to a slot in the object you want to handle the timeout. Any special parameters can be encapsulated in the object as member variables.

Bill.

A.H.M. Mahfuzur Rahman
6th August 2009, 18:53
I can use QTimer as:
QTimer::singleShot(1500, this, SLOT(crossCapture()));

But, can this be used like:
QTimer::singleShot(1500, this, SLOT(crossCapture(int,int)));

If so, please give me an example, how?

faldzip
6th August 2009, 21:41
You can't do this. You can connect signal to slot where slot has less params than signal, but can't do it the other way - because from where that slot should take values for missing arguments?

wrdieter
7th August 2009, 13:52
You could sub-class QTimer and write a new singleShot method that takes the two additional ints that you want to pass as parameters, and stores them in instance variables. It would intercept the standard timeout signal and emit a new timeout signal passing the stored values as parameters.

Bill.