I was trying to add progress bar in qt but got the following error:
error: no matching function for call to 'map(QVector<int>&, <unresolved overloaded function type>)'
futureWatcher.setFuture(QtConcurrent::map(vector, spin));
The code is as follows:
using namespace QtConcurrent;
const int iterations = 20;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QVector<int> vector;
for (int i = 0; i < iterations; ++i)
vector.append(i);
QProgressDialog dialog;
dialog.setLabelText(QString("Progressing using %1 thread(s)...").arg(QThread::idealThreadCount()));
QFutureWatcher<void> futureWatcher;
QObject::connect(&futureWatcher, SIGNAL(progressRangeChanged(int,int)), &dialog, SLOT(setRange(int,int)));
QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &dialog, SLOT(setValue(int)));
futureWatcher.setFuture(QtConcurrent::map(vector, spin));
dialog.exec();
}
void MainWindow::spin(int &iteration)
{
const int work =1000 * 1000 * 40;
volatile int v =0;
for(int j = 0; j< work; j++)
++v;
qDebug()<< "iteration" <<iteration <<"in thread"<<QThread::currentThreadId();
}
I am using Qt5.2.1. Unable to recoganise the error. Please help me to solve the error.