PDA

View Full Version : Use of QTimer



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

wrdieter
6th August 2009, 18: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, 19: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, 22: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, 14: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.