using QTConcurrent with qhash
-
beginner question : i have a QHash.. i am trying to call value method on it under QtConcurrent
QFuture<const int> future = QtConcurrent::run(editorList, &QHash<QString, int>::value, key);
compiler shows following error :
/usr/include/x86_64-linux-gnu/qt5/QtConcurrent/qtconcurrentrunbase.h:90:7: error: uninitialized const member in ‘const int’ [-fpermissive] class RunFunctionTask : public RunFunctionTaskBase<T>
i know i have to initialize const members.. but how??
-
Hi,
What exactly are you trying to accomplish with that
QtConcurrent::run
? -
@SGaist i want to find out value from QHash using key..this function :
https://doc.qt.io/qt-5/qhash.html#value -
@abdullahzubair109 as the QHash is really large, so i was trying to run it in concurrent to prevent gui freezing
-
May I suggest an alternative ?
QFuture<int> future = QtConcurrent::run([=](){ return editorList.value(key); });
On a side note, calling a hash
editorList
is pretty confusing. -
@SGaist well I am convinced to name it something more representative
-
What version of Qt 5 are you using ?
This
QtConcurrent::run(editorList, &QHash<QString, int>::value, key);
basically mean that you want to run the QHash::value method on your editorList variable. There's some kind of issue with the logic here. -
@SGaist i had to use lambda finally.. so marking it solved.