aburbanol
aburbanol

Reputation: 467

QtConcurrent::run right use

I'm trying to use a function that records video by the selected time, so I use a signal to start it but the GUI stays block so I'm trying now to use QtConcurrent::run to do it in a separated thread. I have the class that records so I try to call it from the same class this way:

 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 ....

}

or from somewhere else like this:

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);
}

but I it shows this error:

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

Upvotes: 2

Views: 3368

Answers (1)

Nejat
Nejat

Reputation: 32635

You should provide the pointer to the object and also the address of the class member function. If your function has parameters you can pass them at the end :

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

Upvotes: 3

Related Questions