QtConcurrent with member function

后端 未结 1 1730
孤街浪徒
孤街浪徒 2021-01-06 03:15

I create a QFuture that I want to use to parallelize calls to a member function. More precisely, I have a class solveParallel with .h :

class solverParallel          


        
相关标签:
1条回答
  • 2021-01-06 03:41

    From the official documentation :

    QtConcurrent::run() also accepts pointers to member functions. The first argument must be either a const reference or a pointer to an instance of the class. Passing by const reference is useful when calling const member functions; passing by pointer is useful for calling non-const member functions that modify the instance.

    You are passing a pointer to a pointer. Also notice that you cannot pass the arguments the way you do, but as extra arguments in the run function. The following should work:

    futureComput = QtConcurrent::run(this->myMgr,&Manager::compute, model);
    
    0 讨论(0)
提交回复
热议问题