我使用QtConcurrent::blockingMapped()
在多个线程上的单个参数列表上执行该函数。真的太棒了!
但我想做同样的事情,调用需要多个参数的函数,即:
// prototype:
static void openAndProcess(QString FileName, QImage &image);
这是我的数据:
QList<QString> fileList;
QList<QImage> qImageList;
我想使用上面的 QList
在我的 openAndProcess()
函数上执行 QtConcurrent::blockingMapped()
...
我该怎么做?
提前致谢!
最佳答案
创建一个带有指向数据的指针的 POD 结构。这是无需在 QtConcurrent 中重新实现许多无趣的事情即可做到这一点的唯一方法。
或者,考虑使用 QList<QPair<QString, QImage> >
,这实际上是同一件事。
关于QtConcurrent::blockingMapped 调用函数具有超过 1 个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29430518/