0
我試圖用QtConcurrent:mappedReduced,但它不是與文檔description.I'm獲得4個錯誤與此代碼的簡單:Qt的 - 調用mappedReduced
我使用Qt 5.9。 1 MSVC-2015
//.......................
QMap<QString,QString> TesseractAPI::analyze(QStringList singleData);
void joinMaps(QMap<QString,QString> map, const QMap<QString,QString> partial);
//.............
QMap<QString, QString> TesseractAPI::analyzeAll(QList<QStringList> data){
/*QFuture< QMap<QString,QString> > res*/;
QFuture< QMap<QString,QString> > res = QtConcurrent::mappedReduced(data, TesseractAPI::analyze, joinMaps); // I tried adding '&' before the functors
res.waitForFinished();
qDebug()<<res.result();
return res.result();
}
編譯器錯誤:
C2780: 'QFuture<QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> QtConcurrent::mappedReduced(Iterator,Iterator,MapFunctor,ReduceFunctor,QtConcurrent::ReduceOptions)': expects 5 arguments - 3 provided
C2780: 'QFuture<T> QtConcurrent::mappedReduced(Iterator,Iterator,MapFunctor,ReduceFunctor,QtConcurrent::ReduceOptions)': expects 5 arguments - 3 provided
C2780: 'QFuture<T> QtConcurrent::mappedReduced(Iterator,Iterator,MapFunctor,ReduceFunctor,QtConcurrent::ReduceOptions)': expects 5 arguments - 3 provided
C2783: 'QFuture<T> QtConcurrent::mappedReduced(const Sequence &,MapFunctor,ReduceFunctor,QtConcurrent::ReduceOptions)': could not deduce template argument for 'ResultType'
我試圖改變數據類型,我也跟着個例子e編譯罰款的文檔,但我無法找到問題在我的代碼中持續存在的位置。
我不能把「分析」靜態,因爲它需要訪問私有成員變量 – pourjour
指向成員的指針僅支持容器元素類,即在這種情況下爲QStringList的成員。由於您需要一個不相關對象的無關函數,因此您需要將其包裝到函數對象中,如下所述:http://doc.qt.io/qt-5/qtconcurrentmap.html#using-function-objects – chrisaverage