2

I use QtConcurrent::blockingMapped() to execute the function on the list of single arguments on multiple threads. It's really great!

But I'd like to do same thing calling the function that takes more than one argument, i.e:

// prototype:

static void openAndProcess(QString FileName, QImage &image);

And this is my data:

QList<QString> fileList;
QList<QImage> qImageList;

And I would like to execute QtConcurrent::blockingMapped() on my openAndProcess() function using both above QLists...

How should I do it?

Thanks in advance!

paws
  • 197
  • 1
  • 2
  • 13

1 Answers1

2

Create a POD struct with pointers to the data. This is the only way to do this without reimplementing lots of unfun things in QtConcurrent.

Or, consider using QList<QPair<QString, QImage> >, which is effectively the same thing.

jonspaceharper
  • 4,207
  • 2
  • 22
  • 42
  • OK, thanks. But If I previously had QImage and QString, then creating new instance of structure containing these two types implies that I need to copy data from my QImage to my new structure. It's waste of processor time, isn't it? I need to do this optimally... – paws Apr 16 '15 at 08:06
  • Ah, I meant with pointers to your data. A POD struct of pointers is trivial in overhead. FYI, QImage and QString are implicitly-shared so a deep copy would not occur, but I get your meaning. – jonspaceharper Apr 16 '15 at 09:51
  • I understood, thank you. I accepted your answer, but unfotunately I can't vote for it, because of my low reputation. Cheers! – paws Apr 17 '15 at 08:32