#include #include struct Job { Job(QString _fileName="") : fileName(_fileName) { } void run() { image = QImage(fileName); } QString fileName; QImage image; }; int main(int argc, char* argv[]) { if(argc<2) { qDebug() << "Please supply an image path."; return -1; } // If the following line is uncommented, the application won't crash. // QThreadPool::globalInstance()->setMaxThreadCount(1); QVector jobs(15, Job(argv[1])); QtConcurrent::map(jobs, &Job::run).waitForFinished(); return 0; }