c++ - Linking a function to a timer with Qt -
i have function declaration above:
double image_function(double sum, double avr, double &value)
i have read signals , slots must have same arguments, how possible adjust condition when applyinh timer function follow:
connect(timer, signal(timeout()), this, slot(image_function())); timer->start(0);
that's not possible. function needs 3 parameters, have give them. how timer know function's parameters?
create slot function (without parameters) timer's timeout. there call image_function
parameters want.
let's class mainwindow. need declare slot qtimer's timeout signal:
class mainwindow : public qmainwindow { q_object public: ... private slots: void timer_image_function(); };
then in .cpp, somewhere create qtimer , connect signal new slot:
connect(timer, signal(timeout()), this, slot(timer_image_function())); timer->start(0);
and of course, need implement slot function, calls image_function
:
void mainwindow::timer_image_function() { double result = image_function(sum, avr, value); }
Comments
Post a Comment