Как работать с классом QConcurrent в Qt

Я новичок в Qt. Я начал кодировать эту программу с функциональностью Qt Concurrent. Предполагается, что программа рассчитывает, расходится ли число или сходится к 1. Я предполагаю, что если длина превышает 100, она расходится.

Это мой код

#include <QtConcurrent/QtConcurrentMap>
#include <QFuture>
#include <vector>
#include <iostream>
using namespace std;

bool converges(int &n)
{
int count = 0;
while (count < 100 && n > 1)
{
if (n % 2 == 0)
{
n = n/2;
}
else
{
n = 3*n+1;
}
if(count > 100)
{
break;
}
count = count + 1;
}
if (n = 1 && count <= 100)
return true;
else
return false;
}

int main(int argc, char *argv[])
{
int N = 1000000;
vector <int> data;
for(int i = 0; i < N; i++)
{
data.push_back(i);
}
QFuture <void> res = QtConcurrent::map(data,converges);
res.waitForFinished();
return 0;
}

Но я получаю ошибку сборки. Любые предложения, где я иду не так?

Это ошибка, которую я продолжаю получать

main.obj: -1: ошибка: LNK2019: неразрешенный внешний символ «__declspec (dllimport) public: __thiscall QtConcurrent :: ThreadEngineBase :: ThreadEngineBase (void)» (__imp _ ?? 0ThreadEngineBase @ QtConcurrent @@ QAE @ function «reference public: __thiscall QtConcurrent :: IterateKernel>>, void> :: IterateKernel>>, void> (класс std :: _ Vector_iterator>>, класс std :: _ Vector_iterator>>) «(?? 0? $ IterateKernel @ V? $ _ Vector_iterator @V? $ _ Vector_val @ U? $ _ Simple_types @ H @ станд @@@ @@@ станд станд @@ X @ QtConcurrent @@ QAE @ V? $ _ Vector_iterator @ V? $ _ Vector_val @ U? $ _ Simple_types @ H @ станд @ @@ станд @@@ станд @@ 0 @ Z)

-1

Решение

Как ответил @Mike, добавив QT += concurrent к моему .pro файл работал на меня.

2

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector