I want to write a little program which compress all files from a directory by using qCompress of QByteArray.
However i want to run the compression on a multithreaded environment by using QtConcurrent. But i have some problems.
Here my code :
FilePool pool(folder,suffix);
QFutureWatcher<QString> watcher;
QProgressDialog progressDialog;
connect(&watcher,SIGNAL(progressRangeChanged(int,int)),&progressDialog,SLOT(setRange(int,int)));
connect(&watcher,SIGNAL(progressValueChanged(int)),&progressDialog,SLOT(setValue(int)));
connect(&progressDialog,SIGNAL(canceled()),&watcher,SLOT(cancel()));
QFuture<QString> future = QtConcurrent::filtered(pool,FindInFile(search));
QString text;
watcher.setFuture(future);
progressDialog.exec();
future.waitForFinished();
//Test for compressing file
QFile outFile("testCompress.ecf");
outFile.open(QIODevice::WriteOnly);
QByteArray nonCompressedData;
foreach(const QString &file,future.results()){
//Fichier d'entrée
QFile inFile(file);
inFile.open(QIODevice::ReadOnly);
nonCompressedData.append(inFile.readAll());
inFile.close();
text += file + "\n";
}
//QByteArray compressedData(qCompress(nonCompressedData,9));
//PROBLEM HERE
QFuture<QByteArray> futureCompressor = QtConcurrent::filtered(nonCompressedData,qCompress);
futureCompressor.waitForFinished();
QByteArray compressedData = futureCompressor.results();
outFile.write(compressedData);
The problem is that the compiler raise me an errors
First : No matching function for call to filtered(&QByteArray,).
Second : converstion from QList to non scalar type QByteArray requested.
So, my question is,is it possible to do what i want?
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire