2014-09-10 50 views
2

我试图使用一个功能,记录视频的选定时间,所以我用一个信号来启动它,但GUI保持阻止,所以我现在试图使用QtConcurrent::run做到这一点在分开的线程中。我有记录,所以我尝试从同一类这样叫它类:QtConcurrent ::运行rigre使用

void VideoProcessor::record(int index, int time, int frames, QString path){ 
      QFuture<void> future = QtConcurrent::run(recordAsync,index,time,frames, path); 

} 

void VideoProcessor::recordAsync(int index, int time, int frames, QString path) 
{ 
    recording code .... 

} 

或从别的地方是这样的:

void Controller::StartRecording(int index, int time, int frames, QString path) 
{ 

    QFuture<void> future = QtConcurrent::run(&this->videoProcessor,record,index,time,frames, path); 
    this->videoProcessor->record(index,time,frames,path); 
} 

,但我把它显示这个错误:

error: no matching function for call to 'run(ab::VideoProcessor**, , int&, int&, int&, QString&)' QFuture future = QtConcurrent::run(&this->videoProcessor,record,index,time,frames, path);

回答

1

您应该提供指向对象的指针以及类成员函数的地址。如果你的函数有参数,你可以在最后通过他们:

QFuture<void> future = QtConcurrent::run(this, &VideoProcessor::recordAsync, index, time, frames, path); 
+0

而从别的地方如: 'QFuture 未来= QtConcurrent ::运行(,视频处理器,及,视频处理器::纪录,指数,时间,框架,路径);' – nib 2014-10-21 08:34:19

+0

@aburbanol它解决了问题吗? – Nejat 2015-04-14 03:23:42

+0

@Nejat我完全可以这样做。 – aburbanol 2015-09-15 14:18:34