Passing parameters to run() or start() method in Qthread class
Hi,
I need to pass parameters to the run() method of a Qthread class.
Actually I set this parameters by a class method that inizialize members in the class but i need to pass them directly to run() or start() method.
Is this possible?
Thanks,
Michele
Re: Passing parameters to run() or start() method in Qthread class
Well, you can't pass any parameters to the start method (except priority),
but you can use an intermediate function (something like start_with_params),
that can receive them, set your members, and finally run the thread.
Re: Passing parameters to run() or start() method in Qthread class
How about simply:
Code:
public:
MyThread(...){
m_arg = -1;
}
void setArg(int a){ m_arg = a; }
protected:
void run(){
doSomething(m_arg);
}
private:
int m_arg;
};